basic_block def_bb = bb_for_stmt (def_stmt);
struct loop *def_loop;
edge e;
+ edge_iterator ei;
/* Check that some of the edges entering the EXIT block exits a loop in
that USE is defined. */
- for (e = exit->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, exit->preds)
{
def_loop = find_common_loop (def_bb->loop_father, e->src->loop_father);
if (!flow_bb_inside_loop_p (def_loop, e->dest))
phi = create_phi_node (use, exit);
- for (e = exit->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, exit->preds)
add_phi_arg (&phi, use, e);
SSA_NAME_DEF_STMT (use) = def_stmt;
bitmap def;
int index;
basic_block def_bb = bb_for_stmt (SSA_NAME_DEF_STMT (var));
+ bitmap_iterator bi;
bitmap_clear_bit (livein, def_bb->index);
compute_global_livein (livein, def);
BITMAP_XFREE (def);
- EXECUTE_IF_AND_IN_BITMAP (exits, livein, 0, index,
- add_exit_phis_edge (BASIC_BLOCK (index), var));
+ EXECUTE_IF_AND_IN_BITMAP (exits, livein, 0, index, bi)
+ {
+ add_exit_phis_edge (BASIC_BLOCK (index), var);
+ }
}
/* Add exit phis for the names marked in NAMES_TO_RENAME.
add_exit_phis (bitmap names_to_rename, bitmap *use_blocks, bitmap loop_exits)
{
unsigned i;
+ bitmap_iterator bi;
- EXECUTE_IF_SET_IN_BITMAP (names_to_rename, 0, i,
+ EXECUTE_IF_SET_IN_BITMAP (names_to_rename, 0, i, bi)
{
add_exit_phis_var (ssa_name (i), use_blocks[i], loop_exits);
- });
+ }
}
/* Returns a bitmap of all loop exit edge targets. */
bitmap exits = BITMAP_XMALLOC ();
basic_block bb;
edge e;
+ edge_iterator ei;
FOR_EACH_BB (bb)
{
- for (e = bb->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, bb->preds)
if (e->src != ENTRY_BLOCK_PTR
&& !flow_bb_inside_loop_p (e->src->loop_father, bb))
{
get_stmt_operands (stmt);
- FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_USES)
+ FOR_EACH_SSA_TREE_OPERAND (var, stmt, iter, SSA_OP_ALL_USES | SSA_OP_ALL_KILLS)
find_uses_to_rename_use (bb, var, use_blocks);
}
for (phi = phi_nodes (dest); phi; phi = TREE_CHAIN (phi))
{
- op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, bb->succ);
+ op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, EDGE_SUCC (bb, 0));
name = USE_FROM_PTR (op_p);
basic_block bb;
edge exit;
- if (loop->latch->pred->pred_next)
+ if (EDGE_COUNT (loop->latch->preds) > 1)
return NULL;
- bb = loop->latch->pred->src;
+ bb = EDGE_PRED (loop->latch, 0)->src;
last = last_stmt (bb);
if (TREE_CODE (last) != COND_EXPR)
return NULL;
- exit = bb->succ;
+ exit = EDGE_SUCC (bb, 0);
if (exit->dest == loop->latch)
- exit = exit->succ_next;
+ exit = EDGE_SUCC (bb, 1);
if (flow_bb_inside_loop_p (loop, exit->dest))
return NULL;
unsigned first_new_block;
basic_block bb;
unsigned i;
- tree phi, arg, map, def;
bitmap definitions;
if (!(loops->state & LOOPS_HAVE_SIMPLE_LATCHES))
return false;
/* Readd the removed phi args for e. */
- map = PENDING_STMT (e);
- PENDING_STMT (e) = NULL;
-
- for (phi = phi_nodes (e->dest), arg = map;
- phi;
- phi = TREE_CHAIN (phi), arg = TREE_CHAIN (arg))
- {
- def = TREE_VALUE (arg);
- add_phi_arg (&phi, def, e);
- }
- gcc_assert (arg == NULL);
+ flush_pending_stmts (e);
/* Copy the phi node arguments. */
copy_phi_node_args (first_new_block);
/* Adjust edges appropriately to connect new head with first head
as well as second head. */
- e0 = new_head->succ;
+ e0 = EDGE_SUCC (new_head, 0);
e0->flags &= ~EDGE_FALLTHRU;
e0->flags |= EDGE_FALSE_VALUE;
e1 = make_edge (new_head, first_head, EDGE_TRUE_VALUE);
return new_head;
}
-/* Add phi args using PENDINT_STMT list. */
-
-static void
-lv_update_pending_stmts (edge e)
-{
- basic_block dest;
- tree phi, arg, def;
-
- if (!PENDING_STMT (e))
- return;
-
- dest = e->dest;
-
- for (phi = phi_nodes (dest), arg = PENDING_STMT (e);
- phi;
- phi = TREE_CHAIN (phi), arg = TREE_CHAIN (arg))
- {
- def = TREE_VALUE (arg);
- add_phi_arg (&phi, def, e);
- }
-
- PENDING_STMT (e) = NULL;
-}
-
-
/* Main entry point for Loop Versioning transformation.
This transformation given a condition and a loop, creates
tree_ssa_loop_version (struct loops *loops, struct loop * loop,
tree cond_expr, basic_block *condition_bb)
{
- edge entry, latch_edge, exit;
+ edge entry, latch_edge, exit, true_edge, false_edge;
basic_block first_head, second_head;
int irred_flag;
struct loop *nloop;
*condition_bb = lv_adjust_loop_entry_edge (first_head, second_head, entry,
cond_expr);
- latch_edge = loop->latch->rbi->copy->succ;
+ latch_edge = EDGE_SUCC (loop->latch->rbi->copy, 0);
+
+ extract_true_false_edges_from_block (*condition_bb, &true_edge, &false_edge);
nloop = loopify (loops,
latch_edge,
- loop->header->rbi->copy->pred,
- *condition_bb,
+ EDGE_PRED (loop->header->rbi->copy, 0),
+ *condition_bb, true_edge, false_edge,
false /* Do not redirect all edges. */);
exit = loop->single_exit;
nloop->single_exit = find_edge (exit->src->rbi->copy, exit->dest);
/* loopify redirected latch_edge. Update its PENDING_STMTS. */
- lv_update_pending_stmts (latch_edge);
+ flush_pending_stmts (latch_edge);
/* loopify redirected condition_bb's succ edge. Update its PENDING_STMTS. */
- lv_update_pending_stmts (FALLTHRU_EDGE (*condition_bb));
+ extract_true_false_edges_from_block (*condition_bb, &true_edge, &false_edge);
+ flush_pending_stmts (false_edge);
/* Adjust irreducible flag. */
if (irred_flag)
(*condition_bb)->flags |= BB_IRREDUCIBLE_LOOP;
loop_preheader_edge (loop)->flags |= EDGE_IRREDUCIBLE_LOOP;
loop_preheader_edge (nloop)->flags |= EDGE_IRREDUCIBLE_LOOP;
- (*condition_bb)->pred->flags |= EDGE_IRREDUCIBLE_LOOP;
+ EDGE_PRED ((*condition_bb), 0)->flags |= EDGE_IRREDUCIBLE_LOOP;
}
/* At this point condition_bb is loop predheader with two successors,
first_head and second_head. Make sure that loop predheader has only
- one successor. */
+ one successor. */
loop_split_edge_with (loop_preheader_edge (loop), NULL);
loop_split_edge_with (loop_preheader_edge (nloop), NULL);