aboutsummaryrefslogtreecommitdiff
path: root/gcc/loop-unswitch.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/loop-unswitch.c')
-rw-r--r--gcc/loop-unswitch.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/gcc/loop-unswitch.c b/gcc/loop-unswitch.c
index c1971c6f4c0..4cfaa2f6255 100644
--- a/gcc/loop-unswitch.c
+++ b/gcc/loop-unswitch.c
@@ -81,7 +81,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
static struct loop *unswitch_loop (struct loops *, struct loop *,
basic_block);
static void unswitch_single_loop (struct loops *, struct loop *, rtx, int);
-static bool may_unswitch_on_p (struct loops *, basic_block, struct loop *,
+static bool may_unswitch_on_p (basic_block, struct loop *,
basic_block *);
static rtx reversed_condition (rtx);
@@ -107,7 +107,7 @@ unswitch_loops (struct loops *loops)
unswitch_single_loop (loops, loop, NULL_RTX, 0);
#ifdef ENABLE_CHECKING
- verify_dominators (loops->cfg.dom);
+ verify_dominators (CDI_DOMINATORS);
verify_loop_structure (loops);
#endif
}
@@ -117,8 +117,7 @@ unswitch_loops (struct loops *loops)
basic blocks (for what it means see comments below). List of basic blocks
inside LOOP is provided in BODY to save time. */
static bool
-may_unswitch_on_p (struct loops *loops, basic_block bb, struct loop *loop,
- basic_block *body)
+may_unswitch_on_p (basic_block bb, struct loop *loop, basic_block *body)
{
rtx test;
unsigned i;
@@ -126,7 +125,7 @@ may_unswitch_on_p (struct loops *loops, basic_block bb, struct loop *loop,
/* BB must end in a simple conditional jump. */
if (!bb->succ || !bb->succ->succ_next || bb->succ->succ_next->succ_next)
return false;
- if (!any_condjump_p (bb->end))
+ if (!any_condjump_p (BB_END (bb)))
return false;
/* With branches inside loop. */
@@ -136,17 +135,17 @@ may_unswitch_on_p (struct loops *loops, basic_block bb, struct loop *loop,
/* It must be executed just once each iteration (because otherwise we
are unable to update dominator/irreducible loop information correctly). */
- if (!just_once_each_iteration_p (loops, loop, bb))
+ if (!just_once_each_iteration_p (loop, bb))
return false;
/* Condition must be invariant. We use just a stupid test of invariantness
of the condition: all used regs must not be modified inside loop body. */
- test = get_condition (bb->end, NULL, true);
+ test = get_condition (BB_END (bb), NULL, true);
if (!test)
return false;
for (i = 0; i < loop->num_nodes; i++)
- if (modified_between_p (test, body[i]->head, NEXT_INSN (body[i]->end)))
+ if (modified_between_p (test, BB_HEAD (body[i]), NEXT_INSN (BB_END (body[i]))))
return false;
return true;
@@ -239,7 +238,7 @@ unswitch_single_loop (struct loops *loops, struct loop *loop,
/* Find a bb to unswitch on. */
bbs = get_loop_body (loop);
for (i = 0; i < loop->num_nodes; i++)
- if (may_unswitch_on_p (loops, bbs[i], loop, bbs))
+ if (may_unswitch_on_p (bbs[i], loop, bbs))
break;
if (i == loop->num_nodes)
@@ -248,7 +247,7 @@ unswitch_single_loop (struct loops *loops, struct loop *loop,
return;
}
- if (!(cond = get_condition (bbs[i]->end, &split_before, true)))
+ if (!(cond = get_condition (BB_END (bbs[i]), &split_before, true)))
abort ();
rcond = reversed_condition (cond);
@@ -295,7 +294,7 @@ unswitch_single_loop (struct loops *loops, struct loop *loop,
rconds = cond_checked;
/* Separate condition in a single basic block. */
- bb = split_loop_bb (loops, bbs[i], PREV_INSN (split_before))->dest;
+ bb = split_loop_bb (bbs[i], PREV_INSN (split_before))->dest;
free (bbs);
true_first = !(bb->succ->flags & EDGE_FALLTHRU);
if (rtl_dump_file)
@@ -335,7 +334,7 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on)
if (!unswitch_on->succ || !unswitch_on->succ->succ_next ||
unswitch_on->succ->succ_next->succ_next)
abort ();
- if (!just_once_each_iteration_p (loops, loop, unswitch_on))
+ if (!just_once_each_iteration_p (loop, unswitch_on))
abort ();
if (loop->inner)
abort ();
@@ -345,7 +344,7 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on)
abort ();
/* Will we be able to perform redirection? */
- if (!any_condjump_p (unswitch_on->end))
+ if (!any_condjump_p (BB_END (unswitch_on)))
return NULL;
if (!cfg_layout_can_duplicate_bb_p (unswitch_on))
return NULL;
@@ -382,7 +381,7 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on)
switch_bb->succ->flags &= ~EDGE_IRREDUCIBLE_LOOP;
switch_bb->succ->succ_next->flags &= ~EDGE_IRREDUCIBLE_LOOP;
}
- add_to_dominance_info (loops->cfg.dom, switch_bb);
+ add_to_dominance_info (CDI_DOMINATORS, switch_bb);
unswitch_on->rbi->copy = unswitch_on_alt;
/* Loopify from the copy of LOOP body, constructing the new loop. */
@@ -402,5 +401,9 @@ unswitch_loop (struct loops *loops, struct loop *loop, basic_block unswitch_on)
fix_loop_placement (loop);
fix_loop_placement (nloop);
+ /* Preserve the simple loop preheaders. */
+ loop_split_edge_with (loop_preheader_edge (loop), NULL_RTX);
+ loop_split_edge_with (loop_preheader_edge (nloop), NULL_RTX);
+
return nloop;
}