aboutsummaryrefslogtreecommitdiff
path: root/gcc/cfgloop.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/cfgloop.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/cfgloop.c')
-rw-r--r--gcc/cfgloop.c91
1 files changed, 48 insertions, 43 deletions
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 3add736..2bd0d4c 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -50,18 +50,17 @@ flow_loops_cfg_dump (loops, file)
FILE *file;
{
int i;
- basic_block bb;
if (! loops->num || ! file || ! loops->cfg.dom)
return;
- FOR_ALL_BB (bb)
+ for (i = 0; i < n_basic_blocks; i++)
{
edge succ;
- fprintf (file, ";; %d succs { ", bb->sindex);
- for (succ = bb->succ; succ; succ = succ->succ_next)
- fprintf (file, "%d ", succ->dest->sindex);
+ fprintf (file, ";; %d succs { ", i);
+ for (succ = BASIC_BLOCK (i)->succ; succ; succ = succ->succ_next)
+ fprintf (file, "%d ", succ->dest->index);
flow_nodes_print ("} dom", loops->cfg.dom[i], file);
}
@@ -69,7 +68,7 @@ flow_loops_cfg_dump (loops, file)
if (loops->cfg.dfs_order)
{
fputs (";; DFS order: ", file);
- for (i = 0; i < num_basic_blocks; i++)
+ for (i = 0; i < n_basic_blocks; i++)
fprintf (file, "%d ", loops->cfg.dfs_order[i]);
fputs ("\n", file);
@@ -79,7 +78,7 @@ flow_loops_cfg_dump (loops, file)
if (loops->cfg.rc_order)
{
fputs (";; RC order: ", file);
- for (i = 0; i < num_basic_blocks; i++)
+ for (i = 0; i < n_basic_blocks; i++)
fprintf (file, "%d ", loops->cfg.rc_order[i]);
fputs ("\n", file);
@@ -119,9 +118,9 @@ flow_loop_dump (loop, file, loop_dump_aux, verbose)
loop->shared ? " shared" : "", loop->invalid ? " invalid" : "");
fprintf (file, ";; header %d, latch %d, pre-header %d, first %d, last %d\n",
- loop->header->sindex, loop->latch->sindex,
- loop->pre_header ? loop->pre_header->sindex : -1,
- loop->first->sindex, loop->last->sindex);
+ loop->header->index, loop->latch->index,
+ loop->pre_header ? loop->pre_header->index : -1,
+ loop->first->index, loop->last->index);
fprintf (file, ";; depth %d, level %d, outer %ld\n",
loop->depth, loop->level,
(long) (loop->outer ? loop->outer->num : -1));
@@ -186,7 +185,7 @@ flow_loops_dump (loops, file, loop_dump_aux, verbose)
smaller ? oloop : loop);
fprintf (file,
";; loop header %d shared by loops %d, %d %s\n",
- loop->header->sindex, i, j,
+ loop->header->index, i, j,
disjoint ? "disjoint" : "nested");
}
}
@@ -260,7 +259,7 @@ flow_loop_entry_edges_find (header, nodes, entry_edges)
{
basic_block src = e->src;
- if (src == ENTRY_BLOCK_PTR || ! TEST_BIT (nodes, src->sindex))
+ if (src == ENTRY_BLOCK_PTR || ! TEST_BIT (nodes, src->index))
num_entries++;
}
@@ -274,7 +273,7 @@ flow_loop_entry_edges_find (header, nodes, entry_edges)
{
basic_block src = e->src;
- if (src == ENTRY_BLOCK_PTR || ! TEST_BIT (nodes, src->sindex))
+ if (src == ENTRY_BLOCK_PTR || ! TEST_BIT (nodes, src->index))
(*entry_edges)[num_entries++] = e;
}
@@ -306,7 +305,7 @@ flow_loop_exit_edges_find (nodes, exit_edges)
{
basic_block dest = e->dest;
- if (dest == EXIT_BLOCK_PTR || ! TEST_BIT (nodes, dest->sindex))
+ if (dest == EXIT_BLOCK_PTR || ! TEST_BIT (nodes, dest->index))
num_exits++;
}
});
@@ -323,7 +322,7 @@ flow_loop_exit_edges_find (nodes, exit_edges)
{
basic_block dest = e->dest;
- if (dest == EXIT_BLOCK_PTR || ! TEST_BIT (nodes, dest->sindex))
+ if (dest == EXIT_BLOCK_PTR || ! TEST_BIT (nodes, dest->index))
(*exit_edges)[num_exits++] = e;
}
});
@@ -345,19 +344,19 @@ flow_loop_nodes_find (header, latch, nodes)
int sp;
int num_nodes = 0;
- stack = (basic_block *) xmalloc (num_basic_blocks * sizeof (basic_block));
+ stack = (basic_block *) xmalloc (n_basic_blocks * sizeof (basic_block));
sp = 0;
/* Start with only the loop header in the set of loop nodes. */
sbitmap_zero (nodes);
- SET_BIT (nodes, header->sindex);
+ SET_BIT (nodes, header->index);
num_nodes++;
header->loop_depth++;
/* Push the loop latch on to the stack. */
- if (! TEST_BIT (nodes, latch->sindex))
+ if (! TEST_BIT (nodes, latch->index))
{
- SET_BIT (nodes, latch->sindex);
+ SET_BIT (nodes, latch->index);
latch->loop_depth++;
num_nodes++;
stack[sp++] = latch;
@@ -376,9 +375,9 @@ flow_loop_nodes_find (header, latch, nodes)
/* If each ancestor not marked as part of loop, add to set of
loop nodes and push on to stack. */
if (ancestor != ENTRY_BLOCK_PTR
- && ! TEST_BIT (nodes, ancestor->sindex))
+ && ! TEST_BIT (nodes, ancestor->index))
{
- SET_BIT (nodes, ancestor->sindex);
+ SET_BIT (nodes, ancestor->index);
ancestor->loop_depth++;
num_nodes++;
stack[sp++] = ancestor;
@@ -445,7 +444,7 @@ flow_loop_pre_header_find (header, dom)
basic_block node = e->src;
if (node != ENTRY_BLOCK_PTR
- && ! TEST_BIT (dom[node->sindex], header->sindex))
+ && ! TEST_BIT (dom[node->index], header->index))
{
if (pre_header == NULL)
pre_header = node;
@@ -600,15 +599,15 @@ flow_loop_scan (loops, loop, flags)
/* Determine which loop nodes dominate all the exits
of the loop. */
- loop->exits_doms = sbitmap_alloc (last_basic_block);
+ loop->exits_doms = sbitmap_alloc (n_basic_blocks);
sbitmap_copy (loop->exits_doms, loop->nodes);
for (j = 0; j < loop->num_exits; j++)
sbitmap_a_and_b (loop->exits_doms, loop->exits_doms,
- loops->cfg.dom[loop->exit_edges[j]->src->sindex]);
+ loops->cfg.dom[loop->exit_edges[j]->src->index]);
/* The header of a natural loop must dominate
all exits. */
- if (! TEST_BIT (loop->exits_doms, loop->header->sindex))
+ if (! TEST_BIT (loop->exits_doms, loop->header->index))
abort ();
}
@@ -636,14 +635,14 @@ flow_loops_find (loops, flags)
struct loops *loops;
int flags;
{
- int i, b;
+ int i;
+ int b;
int num_loops;
edge e;
sbitmap headers;
sbitmap *dom;
int *dfs_order;
int *rc_order;
- basic_block header;
/* This function cannot be repeatedly called with different
flags to build up the loop information. The loop tree
@@ -655,21 +654,24 @@ flow_loops_find (loops, flags)
/* Taking care of this degenerate case makes the rest of
this code simpler. */
- if (num_basic_blocks == 0)
+ if (n_basic_blocks == 0)
return 0;
dfs_order = NULL;
rc_order = NULL;
/* Compute the dominators. */
- dom = sbitmap_vector_alloc (last_basic_block, last_basic_block);
+ dom = sbitmap_vector_alloc (n_basic_blocks, n_basic_blocks);
calculate_dominance_info (NULL, dom, CDI_DOMINATORS);
/* Count the number of loop edges (back edges). This should be the
same as the number of natural loops. */
num_loops = 0;
- FOR_ALL_BB (header)
+ for (b = 0; b < n_basic_blocks; b++)
{
+ basic_block header;
+
+ header = BASIC_BLOCK (b);
header->loop_depth = 0;
for (e = header->pred; e; e = e->pred_next)
@@ -682,7 +684,10 @@ flow_loops_find (loops, flags)
loop. It also has single back edge to the header
from a latch node. Note that multiple natural loops
may share the same header. */
- if (latch != ENTRY_BLOCK_PTR && TEST_BIT (dom[latch->sindex], header->sindex))
+ if (b != header->index)
+ abort ();
+
+ if (latch != ENTRY_BLOCK_PTR && TEST_BIT (dom[latch->index], b))
num_loops++;
}
}
@@ -691,8 +696,8 @@ flow_loops_find (loops, flags)
{
/* Compute depth first search order of the CFG so that outer
natural loops will be found before inner natural loops. */
- dfs_order = (int *) xmalloc (num_basic_blocks * sizeof (int));
- rc_order = (int *) xmalloc (num_basic_blocks * sizeof (int));
+ dfs_order = (int *) xmalloc (n_basic_blocks * sizeof (int));
+ rc_order = (int *) xmalloc (n_basic_blocks * sizeof (int));
flow_depth_first_order_compute (dfs_order, rc_order);
/* Save CFG derived information to avoid recomputing it. */
@@ -704,16 +709,16 @@ flow_loops_find (loops, flags)
loops->array
= (struct loop *) xcalloc (num_loops, sizeof (struct loop));
- headers = sbitmap_alloc (last_basic_block);
+ headers = sbitmap_alloc (n_basic_blocks);
sbitmap_zero (headers);
- loops->shared_headers = sbitmap_alloc (last_basic_block);
+ loops->shared_headers = sbitmap_alloc (n_basic_blocks);
sbitmap_zero (loops->shared_headers);
/* Find and record information about all the natural loops
in the CFG. */
num_loops = 0;
- for (b = num_basic_blocks - 1; b >= 0; b--)
+ for (b = n_basic_blocks - 1; b >= 0; b--)
{
basic_block latch;
@@ -733,7 +738,7 @@ flow_loops_find (loops, flags)
latch node. Note that multiple natural loops may share
the same header. */
if (header != EXIT_BLOCK_PTR
- && TEST_BIT (dom[latch->sindex], header->sindex))
+ && TEST_BIT (dom[latch->index], header->index))
{
struct loop *loop;
@@ -754,12 +759,12 @@ flow_loops_find (loops, flags)
/* Keep track of blocks that are loop headers so
that we can tell which loops should be merged. */
- if (TEST_BIT (headers, loop->header->sindex))
- SET_BIT (loops->shared_headers, loop->header->sindex);
- SET_BIT (headers, loop->header->sindex);
+ if (TEST_BIT (headers, loop->header->index))
+ SET_BIT (loops->shared_headers, loop->header->index);
+ SET_BIT (headers, loop->header->index);
/* Find nodes contained within the loop. */
- loop->nodes = sbitmap_alloc (last_basic_block);
+ loop->nodes = sbitmap_alloc (n_basic_blocks);
loop->num_nodes
= flow_loop_nodes_find (loop->header, loop->latch, loop->nodes);
@@ -780,7 +785,7 @@ flow_loops_find (loops, flags)
loops and should be merged. For now just mark loops that share
headers. */
for (i = 0; i < num_loops; i++)
- if (TEST_BIT (loops->shared_headers, loops->array[i].header->sindex))
+ if (TEST_BIT (loops->shared_headers, loops->array[i].header->index))
loops->array[i].shared = 1;
sbitmap_free (headers);
@@ -827,5 +832,5 @@ flow_loop_outside_edge_p (loop, e)
abort ();
return (e->src == ENTRY_BLOCK_PTR)
- || ! TEST_BIT (loop->nodes, e->src->sindex);
+ || ! TEST_BIT (loop->nodes, e->src->index);
}