haifa-sched.c (find_rgns): In no_loops case, fix test for leaf blocks.

* haifa-sched.c (find_rgns): In no_loops case, fix test for leaf
        blocks.  Check for 1 successor which is the EXIT_BLOCK.
        * haifa-sched.c (find_rgns): Detect unreachable blocks, including
        unreachable loops with more than one block.

Co-Authored-By: Jim Wilson <wilson@cygnus.com>

From-SVN: r19558
This commit is contained in:
Jeffrey A Law 1998-05-06 00:12:15 +00:00 committed by Jeff Law
parent 0fac6b0b32
commit 15ebe47d89
2 changed files with 161 additions and 126 deletions

View file

@ -1,3 +1,12 @@
Wed May 6 01:09:01 1998 Jeffrey A Law (law@cygnus.com)
Jim Wilson (wilson@cygnus.com)
* haifa-sched.c (find_rgns): In no_loops case, fix test for leaf
blocks. Check for 1 successor which is the EXIT_BLOCK.
* haifa-sched.c (find_rgns): Detect unreachable blocks, including
unreachable loops with more than one block.
Wed May 6 08:22:24 1998 Manfred Hollstein <manfred@s-direktnet.de>
* fix-header.c (write_rbrac): Add "abort" to functions which need to

View file

@ -1162,8 +1162,13 @@ build_control_flow (s_preds, s_succs, num_preds, num_succs)
for (i = 0; i < n_basic_blocks; i++)
{
nr_edges += num_succs[i];
/* ??? We must also detect unreachable loops here. We only handle the
trivial case of a loop with one basic block for now. */
/* Unreachable loops with more than one basic block are detected
during the DFS traversal in find_rgns.
Unreachable loops with a single block are detected here. This
test is redundant with the one in find_rgns, but it's much
cheaper to go ahead and catch the trivial case here. */
if (num_preds[i] == 0
|| (num_preds[i] == 1 && INT_LIST_VAL (s_preds[i]) == i))
unreachable = 1;
@ -1487,7 +1492,7 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
char no_loops = 1;
int node, child, loop_head, i, j, head, tail;
int count = 0, sp, idx = 0, current_edge = out_edges[0];
int num_bbs, num_insns;
int num_bbs, num_insns, unreachable;
int too_large_failure;
/* Note if an edge has been passed. */
@ -1598,13 +1603,20 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
current_edge = OUT_EDGES (child);
}
/* ?!? This might be a good place to detect unreachable loops and
avoid problems with them by forcing single block scheduling. */
if (no_loops)
SET_BIT (header, 0);
/* Another check for unreachable blocks. The earlier test in
is_cfg_nonregular only finds unreachable blocks that do not
form a loop.
/* Second travsersal:find reducible inner loops and topologically sort
block of each region. */
The DFS traversal will mark every block that is reachable from
the entry node by placing a nonzero value in dfs_nr. Thus if
dfs_nr is zero for any block, then it must be unreachable. */
unreachable = 0;
for (i = 0; i < n_basic_blocks; i++)
if (dfs_nr[i] == 0)
{
unreachable = 1;
break;
}
/* Gross. To avoid wasting memory, the second pass uses the dfs_nr array
to hold degree counts. */
@ -1614,6 +1626,16 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
for (i = 0; i < n_basic_blocks; i++)
degree[i] = num_preds[i];
/* Do not perform region scheduling if there are any unreachable
blocks. */
if (!unreachable)
{
if (no_loops)
SET_BIT (header, 0);
/* Second travsersal:find reducible inner loops and topologically sort
block of each region. */
queue = (int *) alloca (n_basic_blocks * sizeof (int));
/* Find blocks which are inner loop headers. */
@ -1638,8 +1660,8 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
/* Estimate # insns, and count # blocks in the region. */
num_bbs = 1;
num_insns
= INSN_LUID (basic_block_end[i]) - INSN_LUID (basic_block_head[i]);
num_insns = (INSN_LUID (basic_block_end[i])
- INSN_LUID (basic_block_head[i]));
/* Find all loop latches (blocks which back edges to the loop
@ -1649,7 +1671,10 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
if (no_loops)
{
for (j = 0; j < n_basic_blocks; j++)
if (num_succs[j] == 0)
/* Leaf nodes have only a single successor which must
be EXIT_BLOCK. */
if (num_succs[j] == 1
&& INT_LIST_VAL (s_succs[j]) == EXIT_BLOCK)
{
queue[++tail] = j;
SET_BIT (in_queue, j);
@ -1790,6 +1815,7 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
}
}
}
}
/* Any block that did not end up in a region is placed into a region
by itself. */