2012-11-28 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Nov 2012 12:18:39 +0000 (12:18 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Nov 2012 12:18:39 +0000 (12:18 +0000)
PR tree-optimization/54547
* tree-vrp.c (set_and_canonicalize_value_range): Handle
1-bit anti-ranges explicitely.
(extract_range_from_assert): Properly canonicalize all
built anti-ranges.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193888 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-vrp.c

index 4890147..128062d 100644 (file)
@@ -1,3 +1,11 @@
+2012-11-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/54547
+       * tree-vrp.c (set_and_canonicalize_value_range): Handle
+       1-bit anti-ranges explicitely.
+       (extract_range_from_assert): Properly canonicalize all
+       built anti-ranges.
+
 2012-11-28  Eric Botcazou  <ebotcazou@adacore.com>
 
        * stor-layout.c (layout_type) <ARRAY_TYPE>: Do not clear TREE_OVERFLOW
index c9e4e31..dc03db5 100644 (file)
@@ -541,22 +541,15 @@ set_and_canonicalize_value_range (value_range_t *vr, enum value_range_type t,
          return;
        }
       else if (TYPE_PRECISION (TREE_TYPE (min)) == 1
-              && !TYPE_UNSIGNED (TREE_TYPE (min))
               && (is_min || is_max))
        {
-         /* For signed 1-bit precision, one is not in-range and
-            thus adding/subtracting it would result in overflows.  */
-         if (operand_equal_p (min, max, 0))
-           {
-             min = max = is_min ? vrp_val_max (TREE_TYPE (min))
-                                : vrp_val_min (TREE_TYPE (min));
-             t = VR_RANGE;
-           }
+         /* Non-empty boolean ranges can always be represented
+            as a singleton range.  */
+         if (is_min)
+           min = max = vrp_val_max (TREE_TYPE (min));
          else
-           {
-             set_value_range_to_varying (vr);
-             return;
-           }
+           min = max = vrp_val_min (TREE_TYPE (min));
+         t = VR_RANGE;
        }
       else if (is_min
               /* As a special exception preserve non-null ranges.  */
@@ -1707,7 +1700,8 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
          && vrp_val_is_max (max))
        min = max = limit;
 
-      set_value_range (vr_p, VR_ANTI_RANGE, min, max, vr_p->equiv);
+      set_and_canonicalize_value_range (vr_p, VR_ANTI_RANGE,
+                                       min, max, vr_p->equiv);
     }
   else if (cond_code == LE_EXPR || cond_code == LT_EXPR)
     {