aboutsummaryrefslogtreecommitdiff
path: root/gcc/ssa.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/ssa.c')
-rw-r--r--gcc/ssa.c82
1 files changed, 40 insertions, 42 deletions
diff --git a/gcc/ssa.c b/gcc/ssa.c
index 686339c..9fada95 100644
--- a/gcc/ssa.c
+++ b/gcc/ssa.c
@@ -470,18 +470,18 @@ find_evaluations (evals, nregs)
sbitmap *evals;
int nregs;
{
- int bb;
+ basic_block bb;
sbitmap_vector_zero (evals, nregs);
fe_evals = evals;
- for (bb = n_basic_blocks; --bb >= 0; )
+ FOR_EACH_BB_REVERSE (bb)
{
rtx p, last;
- fe_current_bb = bb;
- p = BLOCK_HEAD (bb);
- last = BLOCK_END (bb);
+ fe_current_bb = bb->index;
+ p = bb->head;
+ last = bb->end;
while (1)
{
if (INSN_P (p))
@@ -520,7 +520,7 @@ compute_dominance_frontiers_1 (frontiers, idom, bb, done)
{
basic_block b = BASIC_BLOCK (bb);
edge e;
- int c;
+ basic_block c;
SET_BIT (done, bb);
sbitmap_zero (frontiers[bb]);
@@ -528,9 +528,9 @@ compute_dominance_frontiers_1 (frontiers, idom, bb, done)
/* Do the frontier of the children first. Not all children in the
dominator tree (blocks dominated by this one) are children in the
CFG, so check all blocks. */
- for (c = 0; c < n_basic_blocks; ++c)
- if (idom[c] == bb && ! TEST_BIT (done, c))
- compute_dominance_frontiers_1 (frontiers, idom, c, done);
+ FOR_EACH_BB (c)
+ if (idom[c->index] == bb && ! TEST_BIT (done, c->index))
+ compute_dominance_frontiers_1 (frontiers, idom, c->index, done);
/* Find blocks conforming to rule (1) above. */
for (e = b->succ; e; e = e->succ_next)
@@ -542,11 +542,11 @@ compute_dominance_frontiers_1 (frontiers, idom, bb, done)
}
/* Find blocks conforming to rule (2). */
- for (c = 0; c < n_basic_blocks; ++c)
- if (idom[c] == bb)
+ FOR_EACH_BB (c)
+ if (idom[c->index] == bb)
{
int x;
- EXECUTE_IF_SET_IN_SBITMAP (frontiers[c], 0, x,
+ EXECUTE_IF_SET_IN_SBITMAP (frontiers[c->index], 0, x,
{
if (idom[x] != bb)
SET_BIT (frontiers[bb], x);
@@ -975,7 +975,7 @@ rename_block (bb, idom)
edge e;
rtx insn, next, last;
struct rename_set_data *set_data = NULL;
- int c;
+ basic_block c;
/* Step One: Walk the basic block, adding new names for sets and
replacing uses. */
@@ -1078,9 +1078,9 @@ rename_block (bb, idom)
/* Step Three: Do the same to the children of this block in
dominator order. */
- for (c = 0; c < n_basic_blocks; ++c)
- if (idom[c] == bb)
- rename_block (c, idom);
+ FOR_EACH_BB (c)
+ if (idom[c->index] == bb)
+ rename_block (c->index, idom);
/* Step Four: Update the sets to refer to their new register,
and restore ssa_rename_to to its previous state. */
@@ -1140,6 +1140,8 @@ convert_to_ssa ()
int nregs;
+ basic_block bb;
+
/* Don't do it twice. */
if (in_ssa_form)
abort ();
@@ -1154,10 +1156,9 @@ convert_to_ssa ()
if (rtl_dump_file)
{
- int i;
fputs (";; Immediate Dominators:\n", rtl_dump_file);
- for (i = 0; i < n_basic_blocks; ++i)
- fprintf (rtl_dump_file, ";\t%3d = %3d\n", i, idom[i]);
+ FOR_EACH_BB (bb)
+ fprintf (rtl_dump_file, ";\t%3d = %3d\n", bb->index, idom[bb->index]);
fflush (rtl_dump_file);
}
@@ -1629,7 +1630,7 @@ make_equivalent_phi_alternatives_equivalent (bb, reg_partition)
static partition
compute_conservative_reg_partition ()
{
- int bb;
+ basic_block bb;
int changed = 0;
/* We don't actually work with hard registers, but it's easier to
@@ -1642,8 +1643,8 @@ compute_conservative_reg_partition ()
be copied on abnormal critical edges are placed in the same
partition. This saves us from having to split abnormal critical
edges. */
- for (bb = n_basic_blocks; --bb >= 0; )
- changed += make_regs_equivalent_over_bad_edges (bb, p);
+ FOR_EACH_BB_REVERSE (bb)
+ changed += make_regs_equivalent_over_bad_edges (bb->index, p);
/* Now we have to insure that corresponding arguments of phi nodes
assigning to corresponding regs are equivalent. Iterate until
@@ -1651,8 +1652,8 @@ compute_conservative_reg_partition ()
while (changed > 0)
{
changed = 0;
- for (bb = n_basic_blocks; --bb >= 0; )
- changed += make_equivalent_phi_alternatives_equivalent (bb, p);
+ FOR_EACH_BB_REVERSE (bb)
+ changed += make_equivalent_phi_alternatives_equivalent (bb->index, p);
}
return p;
@@ -1848,7 +1849,7 @@ coalesce_regs_in_successor_phi_nodes (bb, p, conflicts)
static partition
compute_coalesced_reg_partition ()
{
- int bb;
+ basic_block bb;
int changed = 0;
regset_head phi_set_head;
regset phi_set = &phi_set_head;
@@ -1860,8 +1861,8 @@ compute_coalesced_reg_partition ()
be copied on abnormal critical edges are placed in the same
partition. This saves us from having to split abnormal critical
edges (which can't be done). */
- for (bb = n_basic_blocks; --bb >= 0; )
- make_regs_equivalent_over_bad_edges (bb, p);
+ FOR_EACH_BB_REVERSE (bb)
+ make_regs_equivalent_over_bad_edges (bb->index, p);
INIT_REG_SET (phi_set);
@@ -1883,12 +1884,11 @@ compute_coalesced_reg_partition ()
blocks first, so that most frequently executed copies would
be more likely to be removed by register coalescing. But any
order will generate correct, if non-optimal, results. */
- for (bb = n_basic_blocks; --bb >= 0; )
+ FOR_EACH_BB_REVERSE (bb)
{
- basic_block block = BASIC_BLOCK (bb);
- changed += coalesce_regs_in_copies (block, p, conflicts);
+ changed += coalesce_regs_in_copies (bb, p, conflicts);
changed +=
- coalesce_regs_in_successor_phi_nodes (block, p, conflicts);
+ coalesce_regs_in_successor_phi_nodes (bb, p, conflicts);
}
conflict_graph_delete (conflicts);
@@ -2094,11 +2094,10 @@ static void
rename_equivalent_regs (reg_partition)
partition reg_partition;
{
- int bb;
+ basic_block b;
- for (bb = n_basic_blocks; --bb >= 0; )
+ FOR_EACH_BB_REVERSE (b)
{
- basic_block b = BASIC_BLOCK (bb);
rtx next = b->head;
rtx last = b->end;
rtx insn;
@@ -2141,7 +2140,7 @@ rename_equivalent_regs (reg_partition)
void
convert_from_ssa ()
{
- int bb;
+ basic_block b, bb;
partition reg_partition;
rtx insns = get_insns ();
@@ -2167,9 +2166,8 @@ convert_from_ssa ()
rename_equivalent_regs (reg_partition);
/* Eliminate the PHI nodes. */
- for (bb = n_basic_blocks; --bb >= 0; )
+ FOR_EACH_BB_REVERSE (b)
{
- basic_block b = BASIC_BLOCK (bb);
edge e;
for (e = b->pred; e; e = e->pred_next)
@@ -2180,17 +2178,17 @@ convert_from_ssa ()
partition_delete (reg_partition);
/* Actually delete the PHI nodes. */
- for (bb = n_basic_blocks; --bb >= 0; )
+ FOR_EACH_BB_REVERSE (bb)
{
- rtx insn = BLOCK_HEAD (bb);
+ rtx insn = bb->head;
while (1)
{
/* If this is a PHI node delete it. */
if (PHI_NODE_P (insn))
{
- if (insn == BLOCK_END (bb))
- BLOCK_END (bb) = PREV_INSN (insn);
+ if (insn == bb->end)
+ bb->end = PREV_INSN (insn);
insn = delete_insn (insn);
}
/* Since all the phi nodes come at the beginning of the
@@ -2199,7 +2197,7 @@ convert_from_ssa ()
else if (INSN_P (insn))
break;
/* If we've reached the end of the block, stop. */
- else if (insn == BLOCK_END (bb))
+ else if (insn == bb->end)
break;
else
insn = NEXT_INSN (insn);