re PR tree-optimization/77479 (Compile time hog w/ -O2 (-Os))
authorRichard Biener <rguenther@suse.de>
Tue, 6 Sep 2016 12:51:01 +0000 (12:51 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 6 Sep 2016 12:51:01 +0000 (12:51 +0000)
2016-09-06  Richard Biener  <rguenther@suse.de>

PR tree-optimization/77479
* tree-vrp.c (update_value_range): Extend overflow handling to
VARYING.

* gcc.dg/torture/pr77479.c: New testcase.

From-SVN: r240007

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr77479.c [new file with mode: 0644]
gcc/tree-vrp.c

index 4335b9d86ced5f716beb8f3e906635e187c9731e..87910e442016a7a2af47fc18f8c1008aa3c29943 100644 (file)
@@ -1,3 +1,9 @@
+2016-09-06  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/77479
+       * tree-vrp.c (update_value_range): Extend overflow handling to
+       VARYING.
+
 2016-09-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/77476
index 28409ccf06283157fe09bf4a90e6fc9b78d51c52..9fcda6e77a08f127328490552873886c738f721c 100644 (file)
@@ -1,3 +1,8 @@
+2016-09-06  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/77479
+       * gcc.dg/torture/pr77479.c: New testcase.
+
 2016-09-06  Richard Biener  <rguenther@suse.de>
 
        PR c/77450
diff --git a/gcc/testsuite/gcc.dg/torture/pr77479.c b/gcc/testsuite/gcc.dg/torture/pr77479.c
new file mode 100644 (file)
index 0000000..354ae59
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fstrict-overflow -ftree-vrp" } */
+
+void
+vr (int of, unsigned char bw)
+{
+  int d1;
+  int lm = 0;
+
+  for (d1 = 0; d1 < 3; ++d1)
+    {
+      const int vl = 2;
+
+      while (bw < vl)
+       {
+       }
+      if (bw != vl)
+       lm -= vl;
+    }
+  while (++of < 1)
+    {
+      lm /= bw;
+      of += lm;
+    }
+}
index 45882c438ba81094b2ac1552296a52845dfe1ad5..e7067ab8e6ecc9950f3f8de2653fd32af9454171 100644 (file)
@@ -744,23 +744,29 @@ update_value_range (const_tree var, value_range *new_vr)
       value_range_type rtype = get_range_info (var, &min, &max);
       if (rtype == VR_RANGE || rtype == VR_ANTI_RANGE)
        {
-         value_range nr;
-         nr.type = rtype;
+         tree nr_min, nr_max;
          /* Range info on SSA names doesn't carry overflow information
             so make sure to preserve the overflow bit on the lattice.  */
-         if (new_vr->type == VR_RANGE
-             && is_negative_overflow_infinity (new_vr->min)
-             && wi::eq_p (new_vr->min, min))
-           nr.min = new_vr->min;
+         if (rtype == VR_RANGE
+             && needs_overflow_infinity (TREE_TYPE (var))
+             && (new_vr->type == VR_VARYING
+                 || (new_vr->type == VR_RANGE
+                     && is_negative_overflow_infinity (new_vr->min)))
+             && wi::eq_p (vrp_val_min (TREE_TYPE (var)), min))
+           nr_min = negative_overflow_infinity (TREE_TYPE (var));
          else
-           nr.min = wide_int_to_tree (TREE_TYPE (var), min);
-         if (new_vr->type == VR_RANGE
-             && is_positive_overflow_infinity (new_vr->max)
-             && wi::eq_p (new_vr->max, max))
-           nr.max = new_vr->max;
+           nr_min = wide_int_to_tree (TREE_TYPE (var), min);
+         if (rtype == VR_RANGE
+             && needs_overflow_infinity (TREE_TYPE (var))
+             && (new_vr->type == VR_VARYING
+                 || (new_vr->type == VR_RANGE
+                     && is_positive_overflow_infinity (new_vr->max)))
+             && wi::eq_p (vrp_val_max (TREE_TYPE (var)), max))
+           nr_max = positive_overflow_infinity (TREE_TYPE (var));
          else
-           nr.max = wide_int_to_tree (TREE_TYPE (var), max);
-         nr.equiv = NULL;
+           nr_max = wide_int_to_tree (TREE_TYPE (var), max);
+         value_range nr = VR_INITIALIZER;
+         set_and_canonicalize_value_range (&nr, rtype, nr_min, nr_max, NULL);
          vrp_intersect_ranges (new_vr, &nr);
        }
     }