re PR middle-end/80764 (ICE at -O3 in both 32-bit and 64-bit modes on x86_64-linux...
authorRichard Biener <rguenther@suse.de>
Fri, 19 May 2017 08:23:37 +0000 (08:23 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 19 May 2017 08:23:37 +0000 (08:23 +0000)
2017-05-19  Richard Biener  <rguenther@suse.de>

PR middle-end/80764
* cfgexpand.c (expand_gimple_cond): Fix loop fixup.

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

From-SVN: r248261

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr80764.c [new file with mode: 0644]

index 23f9b69074bdf00b01bcc5d82ed13dc374a3f2d1..aae3fdded7efc5dc77aa089913308133c66bf085 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-19  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/80764
+       * cfgexpand.c (expand_gimple_cond): Fix loop fixup.
+
 2017-05-18  Segher Boessenkool  <segher@kernel.crashing.org>
 
        * config/rs6000/rs6000.c (struct machine_function): Add field
index e38c8e4ac49c800e7e98ff720679b62482cc26a6..9965310353e6d9d93612d999fcf3d4c4bd1d530e 100644 (file)
@@ -2503,7 +2503,10 @@ expand_gimple_cond (basic_block bb, gcond *stmt)
   false_edge->flags |= EDGE_FALLTHRU;
   new_bb->count = false_edge->count;
   new_bb->frequency = EDGE_FREQUENCY (false_edge);
-  add_bb_to_loop (new_bb, bb->loop_father);
+  add_bb_to_loop (new_bb, dest->loop_father);
+  if (bb->loop_father->latch == bb
+      && bb->loop_father->header == dest)
+    bb->loop_father->latch = new_bb;
   new_edge = make_edge (new_bb, dest, 0);
   new_edge->probability = REG_BR_PROB_BASE;
   new_edge->count = new_bb->count;
index c785b02e21134d5e9bf3ad991b0a60fc686bea44..29a19ccbf2a2df79d7eaaa371986b4956941d793 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-19  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/80764
+       * gcc.dg/torture/pr80764.c: New testcase.
+
 2017-05-18  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/80510
diff --git a/gcc/testsuite/gcc.dg/torture/pr80764.c b/gcc/testsuite/gcc.dg/torture/pr80764.c
new file mode 100644 (file)
index 0000000..bc6d8e8
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+int b, d, f, h;
+char e;
+int fn1();
+int main() { return fn1(); }
+int fn1(int p1) {
+    for (; d;)
+      for (; e < 3;) {
+         for (; h;)
+           b = fn1(0);
+         return f;
+      }
+}