identifying a BB representing a self-loop

sean yang seanatpurdue@hotmail.com
Fri May 19 20:05:00 GMT 2006


>From: Daniel Berlin <dberlin@dberlin.org>
>To: sean yang <seanatpurdue@hotmail.com>
>CC: gcc@gcc.gnu.org, seanatpurdue@purdue.edu
>Subject: Re: identifying a BB representing a self-loop
>Date: Fri, 19 May 2006 15:41:30 -0400
>
>sean yang wrote:
> > Some basic blocks may represent a (self) loop, but GCC's internal basic
> > block representation won't show such information explicitly (i.e., it 
>won't
> > store a self-loop edge).
> > My question is, when I walk through basic blocks, can I identify then
> > easily?
> >
> > E.g., Let's say,
> > ----------demo.c------------------------------------
> > int main(){
> >         int i;
> >         int sum = 0;
> >         for (i=0; i< 10; i++){
> >                 sum = sum+i;
> >         }
> > }
> > -----------------------------------------------------
> > If we compile this by "#gcc -c -O -da demo.c, we can see there are only
> > three BBs. Actually, BB1 is a self-looped basic block. But this loop
> > information is not explicitly expressed.
> >
>
>What do you mean "not explicitly expressed".
>
>If you call the loop finding routines (flow_loops_find), and look in the
>result loop information, does it not give you a loop with a single node?

I meant that there is no edge like BB1-->BB1, if BB1 itself is a loop. For 
example,
for (i=0; i<5;i++){
  for (j=0; j<5; j++){
         sum +=j;
  }
}
The control flow graph may looks like this (with -O option): B1 represents 
the inner loop(but no edge showing it's an loop); however, edge "B3-->B0" 
shows the outer loop explicitly.
B0 ---> B1----->B2-->B3
^                          |
  |___________|


But I think your answer (flow_loops_find) may have  already answered my 
original question (how to know B1 is a loop. Thanks for the reply!

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



More information about the Gcc mailing list