cfgloop.c (flow_loops_find): Initialize first and last fields correctly.
authorZdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
Fri, 31 May 2002 11:09:17 +0000 (13:09 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Fri, 31 May 2002 11:09:17 +0000 (11:09 +0000)
* cfgloop.c (flow_loops_find): Initialize first and last fields
correctly.

From-SVN: r54104

gcc/ChangeLog
gcc/cfgloop.c

index 151362c85e02a98c85a75162125a34db55c4a7f9..b2027582869173fa24a41e94184fc184cc75cbfe 100644 (file)
@@ -1,3 +1,8 @@
+2002-05-31  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
+
+       * cfgloop.c (flow_loops_find): Initialize first and last fields
+       correctly.
+
 2002-05-31  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * c-common.c (builtin_define_std): Correct logic.
index aed264172fdd0ed60f28ac5bb76ab549c039129d..7b0c8415d883263ed0ed2d2cba5ea6c357ec61f6 100644 (file)
@@ -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);
        }