aboutsummaryrefslogtreecommitdiff
path: root/gcc/ssa.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2002-05-16 19:31:56 -0700
committerRichard Henderson <rth@gcc.gnu.org>2002-05-16 19:31:56 -0700
commit0b17ab2f5b1184fdb568786f791bc0613e574241 (patch)
tree94c8895c6dde3b282518d4c9951067cd0ac517fd /gcc/ssa.c
parent8ae86b3cd8c96e287714f127879b018ac7fccd7d (diff)
downloadgcc-0b17ab2f5b1184fdb568786f791bc0613e574241.zip
gcc-0b17ab2f5b1184fdb568786f791bc0613e574241.tar.gz
gcc-0b17ab2f5b1184fdb568786f791bc0613e574241.tar.bz2
Revert "Basic block renumbering removal", and two followup patches.
From-SVN: r53537
Diffstat (limited to 'gcc/ssa.c')
-rw-r--r--gcc/ssa.c120
1 files changed, 61 insertions, 59 deletions
diff --git a/gcc/ssa.c b/gcc/ssa.c
index a1dedfb..686339c 100644
--- a/gcc/ssa.c
+++ b/gcc/ssa.c
@@ -430,7 +430,7 @@ remove_phi_alternative (set, block)
int num_elem = GET_NUM_ELEM (phi_vec);
int v, c;
- c = block->sindex;
+ c = block->index;
for (v = num_elem - 2; v >= 0; v -= 2)
if (INTVAL (RTVEC_ELT (phi_vec, v + 1)) == c)
{
@@ -470,18 +470,18 @@ find_evaluations (evals, nregs)
sbitmap *evals;
int nregs;
{
- basic_block bb;
+ int bb;
sbitmap_vector_zero (evals, nregs);
fe_evals = evals;
- FOR_ALL_BB_REVERSE (bb)
+ for (bb = n_basic_blocks; --bb >= 0; )
{
rtx p, last;
- fe_current_bb = bb->sindex;
- p = bb->head;
- last = bb->end;
+ fe_current_bb = bb;
+ p = BLOCK_HEAD (bb);
+ last = BLOCK_END (bb);
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;
- basic_block c;
+ int c;
SET_BIT (done, bb);
sbitmap_zero (frontiers[bb]);
@@ -528,25 +528,25 @@ 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_ALL_BB (c)
- if (idom[c->sindex] == bb && ! TEST_BIT (done, c->sindex))
- compute_dominance_frontiers_1 (frontiers, idom, c->sindex, done);
+ for (c = 0; c < n_basic_blocks; ++c)
+ if (idom[c] == bb && ! TEST_BIT (done, c))
+ compute_dominance_frontiers_1 (frontiers, idom, c, done);
/* Find blocks conforming to rule (1) above. */
for (e = b->succ; e; e = e->succ_next)
{
if (e->dest == EXIT_BLOCK_PTR)
continue;
- if (idom[e->dest->sindex] != bb)
- SET_BIT (frontiers[bb], e->dest->sindex);
+ if (idom[e->dest->index] != bb)
+ SET_BIT (frontiers[bb], e->dest->index);
}
/* Find blocks conforming to rule (2). */
- FOR_ALL_BB (c)
- if (idom[c->sindex] == bb)
+ for (c = 0; c < n_basic_blocks; ++c)
+ if (idom[c] == bb)
{
int x;
- EXECUTE_IF_SET_IN_SBITMAP (frontiers[c->sindex], 0, x,
+ EXECUTE_IF_SET_IN_SBITMAP (frontiers[c], 0, x,
{
if (idom[x] != bb)
SET_BIT (frontiers[bb], x);
@@ -559,7 +559,7 @@ compute_dominance_frontiers (frontiers, idom)
sbitmap *frontiers;
int *idom;
{
- sbitmap done = sbitmap_alloc (last_basic_block);
+ sbitmap done = sbitmap_alloc (n_basic_blocks);
sbitmap_zero (done);
compute_dominance_frontiers_1 (frontiers, idom, 0, done);
@@ -585,7 +585,7 @@ compute_iterated_dominance_frontiers (idfs, frontiers, evals, nregs)
sbitmap worklist;
int reg, passes = 0;
- worklist = sbitmap_alloc (last_basic_block);
+ worklist = sbitmap_alloc (n_basic_blocks);
for (reg = 0; reg < nregs; ++reg)
{
@@ -665,7 +665,7 @@ insert_phi_node (regno, bb)
if (e->src != ENTRY_BLOCK_PTR)
{
RTVEC_ELT (vec, i + 0) = pc_rtx;
- RTVEC_ELT (vec, i + 1) = GEN_INT (e->src->sindex);
+ RTVEC_ELT (vec, i + 1) = GEN_INT (e->src->index);
}
phi = gen_rtx_PHI (VOIDmode, vec);
@@ -975,7 +975,7 @@ rename_block (bb, idom)
edge e;
rtx insn, next, last;
struct rename_set_data *set_data = NULL;
- basic_block c;
+ int 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_ALL_BB (c)
- if (idom[c->sindex] == bb)
- rename_block (c->sindex, idom);
+ for (c = 0; c < n_basic_blocks; ++c)
+ if (idom[c] == bb)
+ rename_block (c, idom);
/* Step Four: Update the sets to refer to their new register,
and restore ssa_rename_to to its previous state. */
@@ -1140,8 +1140,6 @@ convert_to_ssa ()
int nregs;
- basic_block bb;
-
/* Don't do it twice. */
if (in_ssa_form)
abort ();
@@ -1150,27 +1148,28 @@ convert_to_ssa ()
dead code. We'll let the SSA optimizers do that. */
life_analysis (get_insns (), NULL, 0);
- idom = (int *) alloca (last_basic_block * sizeof (int));
- memset ((void *) idom, -1, (size_t) last_basic_block * sizeof (int));
+ idom = (int *) alloca (n_basic_blocks * sizeof (int));
+ memset ((void *) idom, -1, (size_t) n_basic_blocks * sizeof (int));
calculate_dominance_info (idom, NULL, CDI_DOMINATORS);
if (rtl_dump_file)
{
+ int i;
fputs (";; Immediate Dominators:\n", rtl_dump_file);
- FOR_ALL_BB (bb)
- fprintf (rtl_dump_file, ";\t%3d = %3d\n", bb->sindex, idom[bb->sindex]);
+ for (i = 0; i < n_basic_blocks; ++i)
+ fprintf (rtl_dump_file, ";\t%3d = %3d\n", i, idom[i]);
fflush (rtl_dump_file);
}
/* Compute dominance frontiers. */
- dfs = sbitmap_vector_alloc (last_basic_block, last_basic_block);
+ dfs = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
compute_dominance_frontiers (dfs, idom);
if (rtl_dump_file)
{
dump_sbitmap_vector (rtl_dump_file, ";; Dominance Frontiers:",
- "; Basic Block", dfs, last_basic_block);
+ "; Basic Block", dfs, n_basic_blocks);
fflush (rtl_dump_file);
}
@@ -1178,12 +1177,12 @@ convert_to_ssa ()
ssa_max_reg_num = max_reg_num ();
nregs = ssa_max_reg_num;
- evals = sbitmap_vector_alloc (nregs, last_basic_block);
+ evals = sbitmap_vector_alloc (nregs, n_basic_blocks);
find_evaluations (evals, nregs);
/* Compute the iterated dominance frontier for each register. */
- idfs = sbitmap_vector_alloc (nregs, last_basic_block);
+ idfs = sbitmap_vector_alloc (nregs, n_basic_blocks);
compute_iterated_dominance_frontiers (idfs, dfs, evals, nregs);
if (rtl_dump_file)
@@ -1384,7 +1383,7 @@ eliminate_phi (e, reg_partition)
n_nodes = 0;
for (; PHI_NODE_P (insn); insn = next_nonnote_insn (insn))
{
- rtx* preg = phi_alternative (PATTERN (insn), e->src->sindex);
+ rtx* preg = phi_alternative (PATTERN (insn), e->src->index);
rtx tgt = SET_DEST (PATTERN (insn));
rtx reg;
@@ -1446,7 +1445,7 @@ eliminate_phi (e, reg_partition)
insert_insn_on_edge (insn, e);
if (rtl_dump_file)
fprintf (rtl_dump_file, "Emitting copy on edge (%d,%d)\n",
- e->src->sindex, e->dest->sindex);
+ e->src->index, e->dest->index);
sbitmap_free (visited);
out:
@@ -1501,7 +1500,7 @@ make_regs_equivalent_over_bad_edges (bb, reg_partition)
for (e = b->pred; e; e = e->pred_next)
if ((e->flags & EDGE_ABNORMAL) && EDGE_CRITICAL_P (e))
{
- rtx *alt = phi_alternative (set, e->src->sindex);
+ rtx *alt = phi_alternative (set, e->src->index);
int alt_regno;
/* If there is no alternative corresponding to this edge,
@@ -1582,7 +1581,7 @@ make_equivalent_phi_alternatives_equivalent (bb, reg_partition)
/* Scan over edges. */
for (e = b->pred; e; e = e->pred_next)
{
- int pred_block = e->src->sindex;
+ int pred_block = e->src->index;
/* Identify the phi alternatives from both phi
nodes corresponding to this edge. */
rtx *alt = phi_alternative (set, pred_block);
@@ -1630,7 +1629,7 @@ make_equivalent_phi_alternatives_equivalent (bb, reg_partition)
static partition
compute_conservative_reg_partition ()
{
- basic_block bb;
+ int bb;
int changed = 0;
/* We don't actually work with hard registers, but it's easier to
@@ -1643,17 +1642,17 @@ 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_ALL_BB_REVERSE (bb)
- changed += make_regs_equivalent_over_bad_edges (bb->sindex, p);
-
+ for (bb = n_basic_blocks; --bb >= 0; )
+ changed += make_regs_equivalent_over_bad_edges (bb, p);
+
/* Now we have to insure that corresponding arguments of phi nodes
assigning to corresponding regs are equivalent. Iterate until
nothing changes. */
while (changed > 0)
{
changed = 0;
- FOR_ALL_BB_REVERSE (bb)
- changed += make_equivalent_phi_alternatives_equivalent (bb->sindex, p);
+ for (bb = n_basic_blocks; --bb >= 0; )
+ changed += make_equivalent_phi_alternatives_equivalent (bb, p);
}
return p;
@@ -1849,7 +1848,7 @@ coalesce_regs_in_successor_phi_nodes (bb, p, conflicts)
static partition
compute_coalesced_reg_partition ()
{
- basic_block bb;
+ int bb;
int changed = 0;
regset_head phi_set_head;
regset phi_set = &phi_set_head;
@@ -1861,8 +1860,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_ALL_BB_REVERSE (bb)
- make_regs_equivalent_over_bad_edges (bb->sindex, p);
+ for (bb = n_basic_blocks; --bb >= 0; )
+ make_regs_equivalent_over_bad_edges (bb, p);
INIT_REG_SET (phi_set);
@@ -1884,11 +1883,12 @@ 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_ALL_BB_REVERSE (bb)
+ for (bb = n_basic_blocks; --bb >= 0; )
{
- changed += coalesce_regs_in_copies (bb, p, conflicts);
- changed +=
- coalesce_regs_in_successor_phi_nodes (bb, p, conflicts);
+ basic_block block = BASIC_BLOCK (bb);
+ changed += coalesce_regs_in_copies (block, p, conflicts);
+ changed +=
+ coalesce_regs_in_successor_phi_nodes (block, p, conflicts);
}
conflict_graph_delete (conflicts);
@@ -2094,10 +2094,11 @@ static void
rename_equivalent_regs (reg_partition)
partition reg_partition;
{
- basic_block b;
+ int bb;
- FOR_ALL_BB_REVERSE (b)
+ for (bb = n_basic_blocks; --bb >= 0; )
{
+ basic_block b = BASIC_BLOCK (bb);
rtx next = b->head;
rtx last = b->end;
rtx insn;
@@ -2140,7 +2141,7 @@ rename_equivalent_regs (reg_partition)
void
convert_from_ssa ()
{
- basic_block b, bb;
+ int bb;
partition reg_partition;
rtx insns = get_insns ();
@@ -2166,8 +2167,9 @@ convert_from_ssa ()
rename_equivalent_regs (reg_partition);
/* Eliminate the PHI nodes. */
- FOR_ALL_BB_REVERSE (b)
+ for (bb = n_basic_blocks; --bb >= 0; )
{
+ basic_block b = BASIC_BLOCK (bb);
edge e;
for (e = b->pred; e; e = e->pred_next)
@@ -2178,17 +2180,17 @@ convert_from_ssa ()
partition_delete (reg_partition);
/* Actually delete the PHI nodes. */
- FOR_ALL_BB_REVERSE (bb)
+ for (bb = n_basic_blocks; --bb >= 0; )
{
- rtx insn = bb->head;
+ rtx insn = BLOCK_HEAD (bb);
while (1)
{
/* If this is a PHI node delete it. */
if (PHI_NODE_P (insn))
{
- if (insn == bb->end)
- bb->end = PREV_INSN (insn);
+ if (insn == BLOCK_END (bb))
+ BLOCK_END (bb) = PREV_INSN (insn);
insn = delete_insn (insn);
}
/* Since all the phi nodes come at the beginning of the
@@ -2197,7 +2199,7 @@ convert_from_ssa ()
else if (INSN_P (insn))
break;
/* If we've reached the end of the block, stop. */
- else if (insn == bb->end)
+ else if (insn == BLOCK_END (bb))
break;
else
insn = NEXT_INSN (insn);
@@ -2257,7 +2259,7 @@ for_each_successor_phi (bb, fn, data)
{
int result;
rtx phi_set = PATTERN (insn);
- rtx *alternative = phi_alternative (phi_set, bb->sindex);
+ rtx *alternative = phi_alternative (phi_set, bb->index);
rtx phi_src;
/* This phi function may not have an alternative