[PATCH] Fix PR60518, split_block not updating loops properly
Richard Biener
rguenther@suse.de
Fri Mar 14 09:33:00 GMT 2014
The following fixes PR60518 where split_block does not fixup
all loops that the block was a latch of (without simple latches
a latch need not belong to its loop but can be an exit block
of a nested loop).
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
Richard.
2014-03-14 Richard Biener <rguenther@suse.de>
PR middle-end/60518
* cfghooks.c (split_block): Properly adjust all loops the
block was a latch of.
* g++.dg/pr60518.C: New testcase.
Index: gcc/cfghooks.c
===================================================================
*** gcc/cfghooks.c (revision 208536)
--- gcc/cfghooks.c (working copy)
*************** split_block (basic_block bb, void *i)
*** 510,518 ****
if (current_loops != NULL)
{
add_bb_to_loop (new_bb, bb->loop_father);
! if (bb->loop_father->latch == bb)
! bb->loop_father->latch = new_bb;
}
res = make_single_succ_edge (bb, new_bb, EDGE_FALLTHRU);
--- 510,522 ----
if (current_loops != NULL)
{
+ edge_iterator ei;
+ edge e;
add_bb_to_loop (new_bb, bb->loop_father);
! /* Identify all loops bb may have been the latch of and adjust them. */
! FOR_EACH_EDGE (e, ei, new_bb->succs)
! if (e->dest->loop_father->latch == bb)
! e->dest->loop_father->latch = new_bb;
}
res = make_single_succ_edge (bb, new_bb, EDGE_FALLTHRU);
Index: gcc/testsuite/g++.dg/pr60518.C
===================================================================
*** gcc/testsuite/g++.dg/pr60518.C (revision 0)
--- gcc/testsuite/g++.dg/pr60518.C (working copy)
***************
*** 0 ****
--- 1,13 ----
+ // { dg-do compile }
+ // { dg-options "-Os -fprofile-use" }
+
+ int a;
+ int fn1 () { return a == ',' || a == ';'; }
+
+ void fn2 ()
+ {
+ do
+ while (fn1 ())
+ ;
+ while (1);
+ }
More information about the Gcc-patches
mailing list