summaryrefslogtreecommitdiff
path: root/gcc/cfghooks.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-03 11:38:04 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-03 11:38:04 +0000
commit35c67c833b78806f818339542f2db310b18349bd (patch)
tree89c43a99b22d5e7d34c2934ec55d1719cf2bab3a /gcc/cfghooks.c
parentbc05341c10553db8c7abbe942dc5f6e683450a24 (diff)
downloadgcc-35c67c833b78806f818339542f2db310b18349bd.tar.gz
2012-04-03 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52808 * tracer.c (tail_duplicate): Return whether we have duplicated any block. (tracer): If we have duplicated any block, cleanup the CFG. * cfghooks.c (duplicate_block): If we duplicated a loop header but not its loop, destroy the loop because it now has multiple entries. * tree-ssa-threadupdate.c (thread_through_loop_header): Tell the cfg manipulation routines we are not creating a multiple entry loop. * gcc.dg/pr52808.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186104 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfghooks.c')
-rw-r--r--gcc/cfghooks.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c
index 1dca79a70cf..bc1b7a2f582 100644
--- a/gcc/cfghooks.c
+++ b/gcc/cfghooks.c
@@ -1009,18 +1009,28 @@ duplicate_block (basic_block bb, edge e, basic_block after)
{
struct loop *cloop = bb->loop_father;
struct loop *copy = get_loop_copy (cloop);
- add_bb_to_loop (new_bb, copy ? copy : cloop);
- /* If we copied the loop latch block but not the loop, adjust
- loop state.
- ??? If we copied the loop header block but not the loop
- we might either have created a loop copy or a loop with
- multiple entries. In both cases we probably have to
- ditch the loops and arrange for a fixup. */
+ /* If we copied the loop header block but not the loop
+ we have created a loop with multiple entries. Ditch the loop,
+ add the new block to the outer loop and arrange for a fixup. */
if (!copy
- && cloop->latch == bb)
+ && cloop->header == bb)
{
+ add_bb_to_loop (new_bb, loop_outer (cloop));
+ cloop->header = NULL;
cloop->latch = NULL;
- loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES);
+ loops_state_set (LOOPS_NEED_FIXUP);
+ }
+ else
+ {
+ add_bb_to_loop (new_bb, copy ? copy : cloop);
+ /* If we copied the loop latch block but not the loop, adjust
+ loop state. */
+ if (!copy
+ && cloop->latch == bb)
+ {
+ cloop->latch = NULL;
+ loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES);
+ }
}
}