fix pr78384
authorMichael Matz <matz@suse.de>
Mon, 23 Jan 2017 13:57:31 +0000 (13:57 +0000)
committerMichael Matz <matz@gcc.gnu.org>
Mon, 23 Jan 2017 13:57:31 +0000 (13:57 +0000)
PR tree-optimization/78384
* tree-ssa-loop-split.c (patch_loop_exit): Use correct edge.

testsuite/
PR tree-optimization/78384
* gcc.dg/pr78384.c: New test.

From-SVN: r244811

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr78384.c [new file with mode: 0644]
gcc/tree-ssa-loop-split.c

index 71aaad9bcc482f6b4f7bbcf1d15ef220c1e4ddd3..851fbc5fb190bdab40dd8763d32f723439991305 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-23  Michael Matz  <matz@suse.de>
+
+       PR tree-optimization/78384
+       * tree-ssa-loop-split.c (patch_loop_exit): Use correct edge.
+
 2017-01-23  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/79186
index c64baf573e3469306bf9b5ae261fa654e2a6f7f5..cb4c19d764242fb843d429723011e59331f73a97 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-23  Michael Matz  <matz@suse.de>
+
+       PR tree-optimization/78384
+       * gcc.dg/pr78384.c: New test.
+
 2017-01-23  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/79186
diff --git a/gcc/testsuite/gcc.dg/pr78384.c b/gcc/testsuite/gcc.dg/pr78384.c
new file mode 100644 (file)
index 0000000..d93437d
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR tree-optimization/78384
+   { dg-do compile }
+   { dg-options "-O3 -w -fsplit-loops" } */
+void
+a2 (int wv, int yg, int r9)
+{
+  while (wv < 1)
+    {
+      int vn = r9 % 0;
+
+      while (yg < 1)
+        {
+          int lz;
+
+          for (r9 = 0; r9 < 17; ++r9)
+            {
+            }
+
+ it:
+          lz = (yg++ >= 0) ? 2 : 0;
+          wv = vn < lz;
+        }
+    }
+  goto it;
+}
index 7809db00e124b5e494bde3dea42fff77e1eaa986..f104b2621c035ea3a661b29ce5fa7e0f1bf5ca1f 100644 (file)
@@ -159,7 +159,7 @@ patch_loop_exit (struct loop *loop, gcond *guard, tree nextval, tree newbound,
                             nextval, newbound);
   update_stmt (stmt);
 
-  edge stay = single_pred_edge (loop->latch);
+  edge stay = EDGE_SUCC (exit->src, EDGE_SUCC (exit->src, 0) == exit);
 
   exit->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
   stay->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);