> > Given the new code for BIT_AND_EXPR in edge_info::derive_equivalences for
> > boolean types, I think that the same special treatment must be added for
> > boolean types in the BIT_NOT_EXPR case to preserve the 0-or-1-value
> > invariant.
> > 
> > Bootstrapped/regtested on x86_64-suse-linux, OK for mainline and 8 branch?
> 
> OK.

Thanks.  However, as reported under PR tree-opt/89536, there is an annoying 
oversight in the reasoning: the predicate to be used is not integer_zerop but 
whether bit #0 is 0 or 1.  I have applied the attached fixlet as obviously 
more correct than the current code, but Jakub has a different opinion on the 
whole change so this will probably be revisited in the near future.


        PR tree-optimization/89536
        * tree-ssa-dom.c (edge_info::derive_equivalences) <BIT_NOT_EXPR>: Test
        only whether bit #0 of the value is 0 instead of the entire value.


        * gcc.c-torture/execute/20190228-1.c: New test.

-- 
Eric Botcazou
/* PR tree-optimization/89536 */
/* Testcase by Zhendong Su <s...@cs.ucdavis.edu> */

int a = 1;

int main (void)
{
  a = ~(a && 1); 
  if (a < -1)
    a = ~a;
  
  if (!a)
    __builtin_abort ();

  return 0;
}
Index: tree-ssa-dom.c
===================================================================
--- tree-ssa-dom.c	(revision 269211)
+++ tree-ssa-dom.c	(working copy)
@@ -348,7 +348,7 @@ edge_info::derive_equivalences (tree nam
 		&& TREE_CODE (rhs) == SSA_NAME
 		&& ssa_name_has_boolean_range (rhs))
 	      {
-		if (integer_zerop (value))
+		if ((TREE_INT_CST_LOW (value) & 1) == 0)
 		  res = build_one_cst (TREE_TYPE (rhs));
 		else
 		  res = build_zero_cst (TREE_TYPE (rhs));

Reply via email to