re PR tree-optimization/80901 (ICE on valid code at -Os and above on x86_64-linux...
authorRichard Biener <rguenther@suse.de>
Tue, 30 May 2017 11:08:36 +0000 (11:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 30 May 2017 11:08:36 +0000 (11:08 +0000)
2017-05-30  Richard Biener  <rguenther@suse.de>

PR middle-end/80901
* cfgexpand.c (expand_gimple_cond): Match up loop fixup with
split_edge code.

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

From-SVN: r248681

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

index 433c15a486465b49f292bc527ad7a3c7d04d1f5a..932ab6930a33d407c4aeb11c633541c25c1ea855 100644 (file)
@@ -1,3 +1,9 @@
+2017-05-30  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/80901
+       * cfgexpand.c (expand_gimple_cond): Match up loop fixup with
+       split_edge code.
+
 2017-05-24  Robin Dapp  <rdapp@linux.vnet.ibm.com>
 
        * tree-vect-data-refs.c (vect_get_peeling_costs_all_drs):
index c5b4d70f4a32db3926d565ff378761e306ddd877..698d43b60b45085a97d6db1adbdc1850f50db54d 100644 (file)
@@ -2503,10 +2503,11 @@ 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, dest->loop_father);
-  if (dest->loop_father->latch == bb
-      && dest->loop_father->header == dest)
-    dest->loop_father->latch = new_bb;
+  loop_p loop = find_common_loop (bb->loop_father, dest->loop_father);
+  add_bb_to_loop (new_bb, loop);
+  if (loop->latch == bb
+      && loop->header == dest)
+    loop->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 79bb197a1304f32b9fd39d95babadd4b6b0f7556..e40a3ed63134ce05cf0b56b58f39412e0fc32869 100644 (file)
@@ -1,3 +1,8 @@
+2017-05-30  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/80901
+       * gcc.dg/torture/pr80901.c: New testcase.
+
 2017-05-30  Robin Dapp  <rdapp@linux.vnet.ibm.com>
 
        * gcc.target/s390/vector/vec-nopeel-2.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr80901.c b/gcc/testsuite/gcc.dg/torture/pr80901.c
new file mode 100644 (file)
index 0000000..635d939
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+
+int a, b, c, d;
+
+int fn1 ()
+{
+  int f;
+  if (d)
+    while (c)
+      {
+       for (f = 0; f < 1; f++)
+         {
+           int g[70] = { 0 };
+           if (b)
+             ;
+           else
+             {
+               int h = !b;
+               for (; h; h = 1)
+                 ;
+             }
+         }
+       return 0;
+      }
+  return a;
+}
+
+int main ()
+{
+  fn1 ();
+  return 0;
+}