re PR tree-optimization/77988 (ICE on valid code at -Os and above on x86_64-linux...
authorRichard Biener <rguenther@suse.de>
Mon, 17 Oct 2016 13:46:34 +0000 (13:46 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 17 Oct 2016 13:46:34 +0000 (13:46 +0000)
2016-10-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/77988
* tree-vrp.c (remove_range_assertions): Use replace_uses_by.

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

From-SVN: r241242

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

index b5e65289366d4c99ab4a37f4d77aa5d44fb6a28d..86df616ab8d1421df32f9fa3e3803ddc418ac2c4 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/77988
+       * tree-vrp.c (remove_range_assertions): Use replace_uses_by.
+
 2016-10-17  Marek Polacek  <polacek@redhat.com>
 
        * Makefile.in (C_COMMON_OBJS): Add c-family/c-attribs.o.
index b99ce7b6326d5cb36a1824650bda3c63885dc704..e73fcf59fbf59a51107fde79bb3b663fff4192fd 100644 (file)
@@ -1,3 +1,8 @@
+2016-10-17  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/77988
+       * gcc.dg/torture/pr77988.c: New testcase.
+
 2016-10-17  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
 
        * gcc.dg/pr71636-1.c: New test-case.
diff --git a/gcc/testsuite/gcc.dg/torture/pr77988.c b/gcc/testsuite/gcc.dg/torture/pr77988.c
new file mode 100644 (file)
index 0000000..9db6b9c
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+
+static int a = 2;
+int b[1], c, d;
+
+int main ()
+{ 
+  int e = a, *f = &b[0];
+  if (d)
+    for (e = 0; e < 1; e++)
+      ;
+  if (e)
+    {
+L1:
+      if (b < f)
+       __builtin_abort ();
+      if (*f)
+       c++;
+      return 0;
+    }
+  f = 0;
+  goto L1;
+  return 0;
+}
index 00a08fdff6dd123b53955d3308e7f6c6a86b5ba5..1aebc722f7ada5bf2f1d4a7fbf3a8c978ea2d354 100644 (file)
@@ -6882,7 +6882,6 @@ remove_range_assertions (void)
     for (si = gsi_after_labels (bb), is_unreachable = -1; !gsi_end_p (si);)
       {
        gimple *stmt = gsi_stmt (si);
-       gimple *use_stmt;
 
        if (is_gimple_assign (stmt)
            && gimple_assign_rhs_code (stmt) == ASSERT_EXPR)
@@ -6890,8 +6889,6 @@ remove_range_assertions (void)
            tree lhs = gimple_assign_lhs (stmt);
            tree rhs = gimple_assign_rhs1 (stmt);
            tree var;
-           use_operand_p use_p;
-           imm_use_iterator iter;
 
            var = ASSERT_EXPR_VAR (rhs);
 
@@ -6927,12 +6924,7 @@ remove_range_assertions (void)
              }
 
            /* Propagate the RHS into every use of the LHS.  */
-           FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs)
-             {
-               FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
-                 SET_USE (use_p, var);
-               update_stmt (use_stmt);
-             }
+           replace_uses_by (lhs, var);
 
            /* And finally, remove the copy, it is not needed.  */
            gsi_remove (&si, true);