{
int bb;
edge e;
- basic_block *worklist, *tos;
+ basic_block *worklist, *qin, *qout, *qend;
+ unsigned int qlen;
/* Allocate a worklist array/queue. Entries are only added to the
list if they were not already on the list. So the size is
bounded by the number of basic blocks. */
- tos = worklist
+ qin = qout = worklist
= (basic_block *) xmalloc (sizeof (basic_block) * n_basic_blocks);
/* We want a maximal solution, so make an optimistic initialization of
/* Put every block on the worklist; this is necessary because of the
optimistic initialization of ANTIN above. */
- for (bb = 0; bb < n_basic_blocks; bb++)
+ for (bb = n_basic_blocks - 1; bb >= 0; bb--)
{
- *tos++ = BASIC_BLOCK (bb);
+ *qin++ = BASIC_BLOCK (bb);
BASIC_BLOCK (bb)->aux = BASIC_BLOCK (bb);
}
+
+ qin = worklist;
+ qend = &worklist[n_basic_blocks];
+ qlen = n_basic_blocks;
/* Mark blocks which are predecessors of the exit block so that we
can easily identify them below. */
e->src->aux = EXIT_BLOCK_PTR;
/* Iterate until the worklist is empty. */
- while (tos != worklist)
+ while (qlen)
{
/* Take the first entry off the worklist. */
- basic_block b = *--tos;
+ basic_block b = *qout++;
bb = b->index;
+ qlen--;
+
+ if (qout >= qend)
+ qout = worklist;
if (b->aux == EXIT_BLOCK_PTR)
/* Do not clear the aux field for blocks which are predecessors of
for (e = b->pred; e; e = e->pred_next)
if (!e->src->aux && e->src != ENTRY_BLOCK_PTR)
{
- *tos++ = e->src;
+ *qin++ = e->src;
e->src->aux = e;
+ qlen++;
+ if (qin >= qend)
+ qin = worklist;
}
}
- free (tos);
+ free (worklist);
}
/* Compute the earliest vector for edge based lcm. */
{
int bb, num_edges, i;
edge e;
- basic_block *worklist, *tos;
+ basic_block *worklist, *qin, *qout, *qend;
+ unsigned int qlen;
num_edges = NUM_EDGES (edge_list);
/* Allocate a worklist array/queue. Entries are only added to the
list if they were not already on the list. So the size is
bounded by the number of basic blocks. */
- tos = worklist
+ qin = qout = worklist
= (basic_block *) xmalloc (sizeof (basic_block) * (n_basic_blocks + 1));
/* Initialize a mapping from each edge to its index. */
/* Add all the blocks to the worklist. This prevents an early exit from
the loop given our optimistic initialization of LATER above. */
- for (bb = n_basic_blocks - 1; bb >= 0; bb--)
+ for (bb = 0; bb < n_basic_blocks; bb++)
{
basic_block b = BASIC_BLOCK (bb);
- *tos++ = b;
+ *qin++ = b;
b->aux = b;
}
+ qin = worklist;
+ /* Note that we do not use the last allocated element for our queue,
+ as EXIT_BLOCK is never inserted into it. In fact the above allocation
+ of n_basic_blocks + 1 elements is not encessary. */
+ qend = &worklist[n_basic_blocks];
+ qlen = n_basic_blocks;
/* Iterate until the worklist is empty. */
- while (tos != worklist)
+ while (qlen)
{
/* Take the first entry off the worklist. */
- basic_block b = *--tos;
+ basic_block b = *qout++;
b->aux = NULL;
+ qlen--;
+ if (qout >= qend)
+ qout = worklist;
/* Compute the intersection of LATERIN for each incoming edge to B. */
bb = b->index;
to add the target of the outgoing edge to the worklist. */
&& e->dest != EXIT_BLOCK_PTR && e->dest->aux == 0)
{
- *tos++ = e->dest;
+ *qin++ = e->dest;
e->dest->aux = e;
+ qlen++;
+ if (qin >= qend)
+ qin = worklist;
}
}
laterin[n_basic_blocks],
later[(size_t) e->aux]);
- free (tos);
+ free (worklist);
}
/* Compute the insertion and deletion points for edge based LCM. */
{
int bb;
edge e;
- basic_block *worklist, *tos;
+ basic_block *worklist, *qin, *qout, *qend;
+ unsigned int qlen;
/* Allocate a worklist array/queue. Entries are only added to the
list if they were not already on the list. So the size is
bounded by the number of basic blocks. */
- tos = worklist
+ qin = qout = worklist
= (basic_block *) xmalloc (sizeof (basic_block) * n_basic_blocks);
/* We want a maximal solution. */
/* Put every block on the worklist; this is necessary because of the
optimistic initialization of AVOUT above. */
- for (bb = n_basic_blocks - 1; bb >= 0; bb--)
+ for (bb = 0; bb < n_basic_blocks; bb++)
{
- *tos++ = BASIC_BLOCK (bb);
+ *qin++ = BASIC_BLOCK (bb);
BASIC_BLOCK (bb)->aux = BASIC_BLOCK (bb);
}
+
+ qin = worklist;
+ qend = &worklist[n_basic_blocks];
+ qlen = n_basic_blocks;
/* Mark blocks which are successors of the entry block so that we
can easily identify them below. */
e->dest->aux = ENTRY_BLOCK_PTR;
/* Iterate until the worklist is empty. */
- while (tos != worklist)
+ while (qlen)
{
/* Take the first entry off the worklist. */
- basic_block b = *--tos;
+ basic_block b = *qout++;
bb = b->index;
+ qlen--;
+
+ if (qout >= qend)
+ qout = worklist;
/* If one of the predecessor blocks is the ENTRY block, then the
intersection of avouts is the null set. We can identify such blocks
for (e = b->succ; e; e = e->succ_next)
if (!e->dest->aux && e->dest != EXIT_BLOCK_PTR)
{
- *tos++ = e->dest;
+ *qin++ = e->dest;
e->dest->aux = e;
+ qlen++;
+
+ if (qin >= qend)
+ qin = worklist;
}
}
- free (tos);
+ free (worklist);
}
/* Compute the farthest vector for edge based lcm. */