diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-21 01:50:10 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-12-21 01:50:10 +0000 |
commit | da65f7aac561d4703ad43692175233423bd7bf96 (patch) | |
tree | 32379513001dec81f4dca82b4d14e1161d02c07c /gcc/cfgloop.c | |
parent | 013bea58e1e321b73abbd630dbf293bfab8b6319 (diff) | |
download | gcc-da65f7aac561d4703ad43692175233423bd7bf96.tar.gz |
* cfgloop.c (flow_loops_find): Use the information of the depth
first search order of the CFG correctly when finding natural loops.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48227 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgloop.c')
-rw-r--r-- | gcc/cfgloop.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index cabd2f22299..a94cbfe79b9 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -737,26 +737,26 @@ flow_loops_find (loops, flags) /* Find and record information about all the natural loops in the CFG. */ num_loops = 0; - for (b = 0; b < n_basic_blocks; b++) + for (b = n_basic_blocks - 1; b >= 0; b--) { - basic_block header; + basic_block latch; /* Search the nodes of the CFG in reverse completion order so that we can find outer loops first. */ - header = BASIC_BLOCK (rc_order[b]); + latch = BASIC_BLOCK (rc_order[b]); - /* Look for all the possible latch blocks for this header. */ - for (e = header->pred; e; e = e->pred_next) + /* Look for all the possible headers for this latch block. */ + for (e = latch->succ; e; e = e->succ_next) { - basic_block latch = e->src; - - /* Look for back edges where a predecessor is dominated - by this block. A natural loop has a single entry - node (header) that dominates all the nodes in the - 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 + basic_block header = e->dest; + + /* Look for forward edges where this block is dominated by + a successor of this block. A natural loop has a single + entry node (header) that dominates all the nodes in the + 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 (header != EXIT_BLOCK_PTR && TEST_BIT (dom[latch->index], header->index)) { struct loop *loop; |