re PR tree-optimization/65875 (ICE: Segmentation fault)
authorJakub Jelinek <jakub@redhat.com>
Mon, 27 Apr 2015 11:26:12 +0000 (13:26 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 27 Apr 2015 11:26:12 +0000 (13:26 +0200)
PR tree-optimization/65875
* tree-vrp.c (update_value_range): If in is_new case setting
old_vr to VR_VARYING, also set new_vr to it.  Remove
old_vr->type == VR_VARYING test.
(vrp_visit_phi_node): Return SSA_PROP_VARYING instead of
SSA_PROP_INTERESTING if update_value_range returned true,
but new range is VR_VARYING.

* gcc.c-torture/compile/pr65875.c: New test.

From-SVN: r222458

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

index ceb6dc361bdbc1a7a2cd48978d9dd6158cd4fb3c..ea2fb2a8458f59d75537d9b21a9a685cd8efe9f9 100644 (file)
@@ -1,3 +1,13 @@
+2015-04-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/65875
+       * tree-vrp.c (update_value_range): If in is_new case setting
+       old_vr to VR_VARYING, also set new_vr to it.  Remove
+       old_vr->type == VR_VARYING test.
+       (vrp_visit_phi_node): Return SSA_PROP_VARYING instead of
+       SSA_PROP_INTERESTING if update_value_range returned true,
+       but new range is VR_VARYING.
+
 2015-04-27  Thomas Preud'homme  <thomas.preudhomme@arm.com>
 
        * combine.c (sign_extend_short_imm): New.
index 18a56e868dfc81b6f24a06471ae23723725a244a..c25b518b22b0ca03116ccb5b4ebfde142e34004f 100644 (file)
@@ -1,3 +1,8 @@
+2015-04-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/65875
+       * gcc.c-torture/compile/pr65875.c: New test.
+
 2015-04-25  Marek Polacek  <polacek@redhat.com>
 
        PR c/52085
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr65875.c b/gcc/testsuite/gcc.c-torture/compile/pr65875.c
new file mode 100644 (file)
index 0000000..26d2a25
--- /dev/null
@@ -0,0 +1,24 @@
+/* PR tree-optimization/65875 */
+
+int a, b, c, d, e, f, g;
+
+void
+foo (void)
+{
+  long h = 0, i;
+  if (g < 0)
+    i = -g;
+  for (; b;)
+    for (; c;)
+      if (e)
+       h = 1;
+  for (; f;)
+    if (a)
+      break;
+  if (h > i)
+    while (h > i)
+      {
+       d = 0;
+       h--;
+      }
+}
index e7ab23c0c0b0c56e6186321d9cf2d15111a3731c..0ade55c0b54380ef9a02a5fcc857716ee362b9f8 100644 (file)
@@ -886,13 +886,18 @@ update_value_range (const_tree var, value_range_t *new_vr)
   if (is_new)
     {
       /* Do not allow transitions up the lattice.  The following
-         is slightly more awkward than just new_vr->type < old_vr->type
+        is slightly more awkward than just new_vr->type < old_vr->type
         because VR_RANGE and VR_ANTI_RANGE need to be considered
         the same.  We may not have is_new when transitioning to
-        UNDEFINED or from VARYING.  */
-      if (new_vr->type == VR_UNDEFINED
-         || old_vr->type == VR_VARYING)
-       set_value_range_to_varying (old_vr);
+        UNDEFINED.  If old_vr->type is VARYING, we shouldn't be
+        called.  */
+      if (new_vr->type == VR_UNDEFINED)
+       {
+         BITMAP_FREE (new_vr->equiv);
+         set_value_range_to_varying (old_vr);
+         set_value_range_to_varying (new_vr);
+         return true;
+       }
       else
        set_value_range (old_vr, new_vr->type, new_vr->min, new_vr->max,
                         new_vr->equiv);
@@ -8941,6 +8946,9 @@ update_range:
          fprintf (dump_file, "\n");
        }
 
+      if (vr_result.type == VR_VARYING)
+       return SSA_PROP_VARYING;
+
       return SSA_PROP_INTERESTING;
     }