From 8a72fb761ecbcb9ec734eea3ce550caa08a3d014 Mon Sep 17 00:00:00 2001 From: Zdenek Dvorak Date: Fri, 31 May 2002 13:09:17 +0200 Subject: [PATCH] cfgloop.c (flow_loops_find): Initialize first and last fields correctly. * cfgloop.c (flow_loops_find): Initialize first and last fields correctly. From-SVN: r54104 --- gcc/ChangeLog | 5 +++++ gcc/cfgloop.c | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 151362c85e0..b2027582869 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2002-05-31 Zdenek Dvorak + + * cfgloop.c (flow_loops_find): Initialize first and last fields + correctly. + 2002-05-31 Neil Booth * c-common.c (builtin_define_std): Correct logic. diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index aed264172fd..7b0c8415d88 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -644,7 +644,7 @@ flow_loops_find (loops, flags) sbitmap *dom; int *dfs_order; int *rc_order; - basic_block header; + basic_block header, bb; /* This function cannot be repeatedly called with different flags to build up the loop information. The loop tree @@ -768,10 +768,16 @@ flow_loops_find (loops, flags) These are often the same as the loop header and loop latch respectively, but this is not always the case. */ - loop->first - = BASIC_BLOCK (sbitmap_first_set_bit (loop->nodes)); - loop->last - = BASIC_BLOCK (sbitmap_last_set_bit (loop->nodes)); + + FOR_EACH_BB (bb) + if (TEST_BIT (loop->nodes, bb->index)) + break; + loop->first = bb; + + FOR_EACH_BB_REVERSE (bb) + if (TEST_BIT (loop->nodes, bb->index)) + break; + loop->last = bb; flow_loop_scan (loops, loop, flags); } -- 2.30.2