tree-vrp.c (zero_nonzero_bits_from_vr): Make sure to always return true for constant...
authorRichard Guenther <rguenther@suse.de>
Fri, 5 Aug 2011 07:33:09 +0000 (07:33 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 5 Aug 2011 07:33:09 +0000 (07:33 +0000)
2011-08-05  Richard Guenther  <rguenther@suse.de>

* tree-vrp.c (zero_nonzero_bits_from_vr): Make sure to always
return true for constant integer ranges.
(extract_range_from_binary_expr_1): Simplify BIT_AND_EXPR and
BIT_IOR_EXPR handling.

* gcc.dg/tree-ssa/vrp51.c: Disable CCP.
* gcc.dg/tree-ssa/vrp52.c: Likewise.
* gcc.dg/tree-ssa/vrp53.c: Likewise.

From-SVN: r177423

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vrp51.c
gcc/testsuite/gcc.dg/tree-ssa/vrp52.c
gcc/testsuite/gcc.dg/tree-ssa/vrp53.c
gcc/tree-vrp.c

index 9fa4a4f2757cec01b0289f18c2d298a20e6218bc..5859bea2c350d69962fa58282871e3486bf3555a 100644 (file)
@@ -1,3 +1,10 @@
+2011-08-05  Richard Guenther  <rguenther@suse.de>
+
+       * tree-vrp.c (zero_nonzero_bits_from_vr): Make sure to always
+       return true for constant integer ranges.
+       (extract_range_from_binary_expr_1): Simplify BIT_AND_EXPR and
+       BIT_IOR_EXPR handling.
+
 2011-08-04  Kai Tietz  <ktietz@redhat.com>
 
        * config/i386/i386.c (setup_incoming_varargs_ms_64): Set
index 61c586e36c8658f5f8c335dcd2307e52ab17a88d..666fcd6a1676df35bb363609534f545e7067f876 100644 (file)
@@ -1,3 +1,9 @@
+2011-08-05  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.dg/tree-ssa/vrp51.c: Disable CCP.
+       * gcc.dg/tree-ssa/vrp52.c: Likewise.
+       * gcc.dg/tree-ssa/vrp53.c: Likewise.
+
 2011-08-04  Mikael Morin  <mikael.morin@sfr.fr>
 
        * gfortran.dg/dependency_26.f90: Add a module to the cleanup directive.
index 51c51df6cc9349a18a621bb78a7c36692764508d..94b29766a4509aebb5b47b06475573138bfb6080 100644 (file)
@@ -1,6 +1,6 @@
 /* PR tree-optimization/28632 */
 /* { dg-do compile } */
-/* { dg-options "-O2 -ftree-vrp" } */
+/* { dg-options "-O2 -ftree-vrp -fno-tree-ccp" } */
 /* { dg-require-effective-target int32plus } */
 
 void
index 231d081565cb5d47f51755300f7665b07312b5c4..52ceea6bef59232cfc3dfdb1a83a68d77b9d6bfc 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fno-tree-ccp" } */
 
 int
 foo (unsigned int i, unsigned int j)
index 66bbfb67b90750902328b6d82094d0d27f8402db..4bcd299eedeb0d027356842ea1d23b0513b73d98 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-vrp1 -fno-tree-ccp" } */
 
 int
 f1 (int x)
index f73487bfc03c720519935283514882e45f3fca52..121746efab677f55ca3c4d6d4e2f4c9201252f7c 100644 (file)
@@ -2141,15 +2141,18 @@ static bool
 zero_nonzero_bits_from_vr (value_range_t *vr, double_int *may_be_nonzero,
                           double_int *must_be_nonzero)
 {
+  may_be_nonzero->low = ALL_ONES;
+  may_be_nonzero->high = ALL_ONES;
+  must_be_nonzero->low = 0;
+  must_be_nonzero->high = 0;
   if (range_int_cst_p (vr))
     {
       if (range_int_cst_singleton_p (vr))
        {
          *may_be_nonzero = tree_to_double_int (vr->min);
          *must_be_nonzero = *may_be_nonzero;
-         return true;
        }
-      if (tree_int_cst_sgn (vr->min) >= 0)
+      else if (tree_int_cst_sgn (vr->min) >= 0)
        {
          double_int dmin = tree_to_double_int (vr->min);
          double_int dmax = tree_to_double_int (vr->max);
@@ -2174,13 +2177,9 @@ zero_nonzero_bits_from_vr (value_range_t *vr, double_int *may_be_nonzero,
              may_be_nonzero->low |= mask;
              must_be_nonzero->low &= ~mask;
            }
-         return true;
        }
+      return true;
     }
-  may_be_nonzero->low = ALL_ONES;
-  may_be_nonzero->high = ALL_ONES;
-  must_be_nonzero->low = 0;
-  must_be_nonzero->high = 0;
   return false;
 }
 
@@ -2638,59 +2637,17 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
     }
   else if (code == BIT_AND_EXPR || code == BIT_IOR_EXPR)
     {
-      bool vr0_int_cst_singleton_p, vr1_int_cst_singleton_p;
       bool int_cst_range0, int_cst_range1;
       double_int may_be_nonzero0, may_be_nonzero1;
       double_int must_be_nonzero0, must_be_nonzero1;
-      value_range_t *non_singleton_vr;
-      tree singleton_val;
 
-      vr0_int_cst_singleton_p = range_int_cst_singleton_p (&vr0);
-      vr1_int_cst_singleton_p = range_int_cst_singleton_p (&vr1);
       int_cst_range0 = zero_nonzero_bits_from_vr (&vr0, &may_be_nonzero0,
                                                  &must_be_nonzero0);
       int_cst_range1 = zero_nonzero_bits_from_vr (&vr1, &may_be_nonzero1,
                                                  &must_be_nonzero1);
 
-      singleton_val = (vr0_int_cst_singleton_p ? vr0.min : vr1.min);
-      non_singleton_vr = (vr0_int_cst_singleton_p ? &vr1 : &vr0);
-
       type = VR_RANGE;
-      if (vr0_int_cst_singleton_p && vr1_int_cst_singleton_p)
-       min = max = int_const_binop (code, vr0.max, vr1.max);
-      else if ((vr0_int_cst_singleton_p || vr1_int_cst_singleton_p)
-              && (integer_zerop (singleton_val)
-                  || integer_all_onesp (singleton_val)))
-       {
-         /* If one of the operands is zero for and-case, we know that
- *          the whole expression evaluates zero.
-            If one of the operands has all bits set to one for
-            or-case, we know that the whole expression evaluates
-            to this one.  */
-          min = max = singleton_val;
-          if ((code == BIT_IOR_EXPR
-               && integer_zerop (singleton_val))
-              || (code == BIT_AND_EXPR
-                  && integer_all_onesp (singleton_val)))
-         /* If one of the operands has all bits set to one, we know
-            that the whole expression evaluates to the other one for
-            the and-case.
-            If one of the operands is zero, we know that the whole
-            expression evaluates to the other one for the or-case.  */
-           {
-             type = non_singleton_vr->type;
-             min = non_singleton_vr->min;
-             max = non_singleton_vr->max;
-           }
-         set_value_range (vr, type, min, max, NULL);
-         return;
-       }
-      else if (!int_cst_range0 && !int_cst_range1)
-       {
-         set_value_range_to_varying (vr);
-         return;
-       }
-      else if (code == BIT_AND_EXPR)
+      if (code == BIT_AND_EXPR)
        {
          min = double_int_to_tree (expr_type,
                                    double_int_and (must_be_nonzero0,
@@ -2698,9 +2655,9 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
          max = double_int_to_tree (expr_type,
                                    double_int_and (may_be_nonzero0,
                                                    may_be_nonzero1));
-         if (TREE_OVERFLOW (min) || tree_int_cst_sgn (min) < 0)
+         if (tree_int_cst_sgn (min) < 0)
            min = NULL_TREE;
-         if (TREE_OVERFLOW (max) || tree_int_cst_sgn (max) < 0)
+         if (tree_int_cst_sgn (max) < 0)
            max = NULL_TREE;
          if (int_cst_range0 && tree_int_cst_sgn (vr0.min) >= 0)
            {
@@ -2717,15 +2674,7 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
                max = vr1.max;
            }
        }
-      else if (!int_cst_range0
-              || !int_cst_range1
-              || tree_int_cst_sgn (vr0.min) < 0
-              || tree_int_cst_sgn (vr1.min) < 0)
-       {
-         set_value_range_to_varying (vr);
-         return;
-       }
-      else
+      else if (code == BIT_IOR_EXPR)
        {
          min = double_int_to_tree (expr_type,
                                    double_int_ior (must_be_nonzero0,
@@ -2733,13 +2682,22 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
          max = double_int_to_tree (expr_type,
                                    double_int_ior (may_be_nonzero0,
                                                    may_be_nonzero1));
-         if (TREE_OVERFLOW (min) || tree_int_cst_sgn (min) < 0)
-           min = vr0.min;
-         else
-           min = vrp_int_const_binop (MAX_EXPR, min, vr0.min);
-         if (TREE_OVERFLOW (max) || tree_int_cst_sgn (max) < 0)
+         if (tree_int_cst_sgn (max) < 0)
            max = NULL_TREE;
-         min = vrp_int_const_binop (MAX_EXPR, min, vr1.min);
+         if (int_cst_range0)
+           {
+             if (tree_int_cst_sgn (min) < 0)
+               min = vr0.min;
+             else
+               min = vrp_int_const_binop (MAX_EXPR, min, vr0.min);
+           }
+         if (int_cst_range1)
+           min = vrp_int_const_binop (MAX_EXPR, min, vr1.min);
+       }
+      else
+       {
+         set_value_range_to_varying (vr);
+         return;
        }
     }
   else