* [PATCH] Fix PR80901
@ 2017-05-30 11:10 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2017-05-30 11:10 UTC (permalink / raw)
To: gcc-patches
Third time's a charm.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
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.
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c (revision 248634)
+++ gcc/cfgexpand.c (working copy)
@@ -2503,10 +2503,11 @@ expand_gimple_cond (basic_block bb, gcon
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: gcc/testsuite/gcc.dg/torture/pr80901.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr80901.c (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr80901.c (working copy)
@@ -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;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-30 11:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 11:10 [PATCH] Fix PR80901 Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).