re PR tree-optimization/21030 (ICE in set_value_range building 176.gcc with -O2)
authorKazu Hirata <kazu@cs.umass.edu>
Fri, 29 Apr 2005 16:23:18 +0000 (16:23 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Fri, 29 Apr 2005 16:23:18 +0000 (16:23 +0000)
gcc/
PR tree-optimization/21030
* tree-vrp.c (adjust_range_with_scev): Do not create invalid
ranges where VR->MAX is smaller than VR->MIN.

testsuite/
PR tree-optimization/21030
* gcc.dg/tree-ssa/pr21030.c: New.

From-SVN: r98999

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

index f06eb6cef30787e474f9d7189aad7a71a2f5d448..16e3565911935ff610d9a761a130752ed08d6b4c 100644 (file)
@@ -1,3 +1,9 @@
+2005-04-28  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/21030
+       * tree-vrp.c (adjust_range_with_scev): Do not create invalid
+       ranges where VR->MAX is smaller than VR->MIN.
+
 2005-04-29  Devang Patel  <dpatel@apple.com>
 
        PR tree-optimization/21272
index 81708422136a34f137b8b34abaac1d73644dc4bf..7782528491c0afb6e0dc8bff98f7891443726ace 100644 (file)
@@ -1,3 +1,8 @@
+2005-04-28  Kazu Hirata  <kazu@cs.umass.edu>
+
+       PR tree-optimization/21030
+       * gcc.dg/tree-ssa/pr21030.c: New.
+
 2005-04-29  Devang Patel  <dpatel@apple.com>
 
        PR tree-optimization/21272
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr21030.c b/gcc/testsuite/gcc.c-torture/compile/pr21030.c
new file mode 100644 (file)
index 0000000..b7590c0
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR tree-optimization/21030
+   VRP used to create invalid ranges where VR->MIN is greater than
+   VR->MAX.  */
+
+void
+foo (int unit)
+{
+  int i;
+
+  for (i = 0; unit; i++, unit--)
+    {
+      if (i >= 0)
+       {
+         int j = i;
+         while (j)
+           j--;
+       }
+    }
+}
index 4d0b034f7544626b123892473b745e3392a5dfa3..0fe5c7bcbbbdaec452840a1d4a9ff6db2c14e6b9 100644 (file)
@@ -893,19 +893,40 @@ adjust_range_with_scev (value_range *vr, struct loop *l, tree var)
     }
   else if (vr->type == VR_RANGE)
     {
+      tree min = vr->min;
+      tree max = vr->max;
+
       if (init_is_max)
        {
-         /* INIT is the maximum value.  If INIT is lower than
-            VR->MAX, set VR->MAX to INIT.  */
-         if (compare_values (init, vr->max) == -1)
-           set_value_range (vr, VR_RANGE, vr->min, init);
+         /* INIT is the maximum value.  If INIT is lower than VR->MAX
+            but no smaller than VR->MIN, set VR->MAX to INIT.  */
+         if (compare_values (init, max) == -1)
+           {
+             max = init;
+
+             /* If we just created an invalid range with the minimum
+                greater than the maximum, take the minimum all the
+                way to -INF.  */
+             if (compare_values (min, max) == 1)
+               min = TYPE_MIN_VALUE (TREE_TYPE (min));
+           }
        }
       else
        {
          /* If INIT is bigger than VR->MIN, set VR->MIN to INIT.  */
-         if (compare_values (init, vr->min) == 1)
-           set_value_range (vr, VR_RANGE, init, vr->max);
+         if (compare_values (init, min) == 1)
+           {
+             min = init;
+
+             /* If we just created an invalid range with the minimum
+                greater than the maximum, take the maximum all the
+                way to +INF.  */
+             if (compare_values (min, max) == 1)
+               max = TYPE_MAX_VALUE (TREE_TYPE (max));
+           }
        }
+
+      set_value_range (vr, VR_RANGE, min, max);
     }
 }