Commit 15ebe47d by Jeffrey A Law Committed by Jeff Law

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
parent 0fac6b0b
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> 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 * fix-header.c (write_rbrac): Add "abort" to functions which need to
......
...@@ -1162,8 +1162,13 @@ build_control_flow (s_preds, s_succs, num_preds, num_succs) ...@@ -1162,8 +1162,13 @@ build_control_flow (s_preds, s_succs, num_preds, num_succs)
for (i = 0; i < n_basic_blocks; i++) for (i = 0; i < n_basic_blocks; i++)
{ {
nr_edges += num_succs[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 if (num_preds[i] == 0
|| (num_preds[i] == 1 && INT_LIST_VAL (s_preds[i]) == i)) || (num_preds[i] == 1 && INT_LIST_VAL (s_preds[i]) == i))
unreachable = 1; unreachable = 1;
...@@ -1487,7 +1492,7 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom) ...@@ -1487,7 +1492,7 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
char no_loops = 1; char no_loops = 1;
int node, child, loop_head, i, j, head, tail; int node, child, loop_head, i, j, head, tail;
int count = 0, sp, idx = 0, current_edge = out_edges[0]; 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; int too_large_failure;
/* Note if an edge has been passed. */ /* Note if an edge has been passed. */
...@@ -1598,13 +1603,20 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom) ...@@ -1598,13 +1603,20 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
current_edge = OUT_EDGES (child); current_edge = OUT_EDGES (child);
} }
/* ?!? This might be a good place to detect unreachable loops and /* Another check for unreachable blocks. The earlier test in
avoid problems with them by forcing single block scheduling. */ is_cfg_nonregular only finds unreachable blocks that do not
if (no_loops) form a loop.
SET_BIT (header, 0);
/* Second travsersal:find reducible inner loops and topologically sort The DFS traversal will mark every block that is reachable from
block of each region. */ 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 /* Gross. To avoid wasting memory, the second pass uses the dfs_nr array
to hold degree counts. */ to hold degree counts. */
...@@ -1614,6 +1626,16 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom) ...@@ -1614,6 +1626,16 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
for (i = 0; i < n_basic_blocks; i++) for (i = 0; i < n_basic_blocks; i++)
degree[i] = num_preds[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)); queue = (int *) alloca (n_basic_blocks * sizeof (int));
/* Find blocks which are inner loop headers. */ /* Find blocks which are inner loop headers. */
...@@ -1638,8 +1660,8 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom) ...@@ -1638,8 +1660,8 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
/* Estimate # insns, and count # blocks in the region. */ /* Estimate # insns, and count # blocks in the region. */
num_bbs = 1; num_bbs = 1;
num_insns num_insns = (INSN_LUID (basic_block_end[i])
= INSN_LUID (basic_block_end[i]) - INSN_LUID (basic_block_head[i]); - INSN_LUID (basic_block_head[i]));
/* Find all loop latches (blocks which back edges to the loop /* 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) ...@@ -1649,7 +1671,10 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom)
if (no_loops) if (no_loops)
{ {
for (j = 0; j < n_basic_blocks; j++) 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; queue[++tail] = j;
SET_BIT (in_queue, j); SET_BIT (in_queue, j);
...@@ -1790,6 +1815,7 @@ find_rgns (s_preds, s_succs, num_preds, num_succs, dom) ...@@ -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 /* Any block that did not end up in a region is placed into a region
by itself. */ by itself. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment