re PR tree-optimization/79244 (ice in replace_uses_by, at tree-cfg.c:1866)
authorRichard Biener <rguenther@suse.de>
Fri, 27 Jan 2017 12:24:54 +0000 (12:24 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 27 Jan 2017 12:24:54 +0000 (12:24 +0000)
2017-01-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/79244
* tree-vrp.c (remove_range_assertions): Forcefully propagate
out SSA names even if abnormal.

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

From-SVN: r244973

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

index 2e52f20ecf759ee6f3f23cbfe83723e8a02a773f..41df9bbcc1bec608301028da52f27f3cb160d9b3 100644 (file)
@@ -1,3 +1,9 @@
+2017-01-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79244
+       * tree-vrp.c (remove_range_assertions): Forcefully propagate
+       out SSA names even if abnormal.
+
 2017-01-27  Jakub Jelinek  <jakub@redhat.com>
 
        * realmpfr.h: Poison MPFR_RND{N,Z,U,D}.
index 4f3104ba4ad570219129b4e91d2494bf837f85e4..525a7c7f2145dacb63ab3d02a5daadadb534b74f 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79244
+       * gcc.dg/torture/pr79244.c: New testcase.
+
 2017-01-27  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/cilk-plus/CK/fib-opr-overload.cc (main): Change
diff --git a/gcc/testsuite/gcc.dg/torture/pr79244.c b/gcc/testsuite/gcc.dg/torture/pr79244.c
new file mode 100644 (file)
index 0000000..05143cd
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+long buf[5];
+int bar (void);
+
+int
+foo (int x)
+{
+  int y = __builtin_setjmp (buf);
+  while (x != 3 && x && x && x != 2)
+    x = bar ();
+  return y;
+}
index d7d7a0d3a08c3d1930b38c81d113b3881180e20e..e023244577c838e777db8de0736b5da2199730e8 100644 (file)
@@ -6974,8 +6974,20 @@ remove_range_assertions (void)
                  }
              }
 
-           /* Propagate the RHS into every use of the LHS.  */
-           replace_uses_by (lhs, var);
+           /* Propagate the RHS into every use of the LHS.  For SSA names
+              also propagate abnormals as it merely restores the original
+              IL in this case (an replace_uses_by would assert).  */
+           if (TREE_CODE (var) == SSA_NAME)
+             {
+               imm_use_iterator iter;
+               use_operand_p use_p;
+               gimple *use_stmt;
+               FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs)
+                 FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+                   SET_USE (use_p, var);
+             }
+           else
+             replace_uses_by (lhs, var);
 
            /* And finally, remove the copy, it is not needed.  */
            gsi_remove (&si, true);