This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Loop oddity


In message <200201221708.g0MH8hj4015272@hiauly1.hia.nrc.ca>, "John David Anglin
" writes:
 > Here is a loop oddity that I noticed.  The loop 
 > 
 >   for (i = 1000000; i; i--) {};
 > 
 > yields the following assembly code when compiled at -O2 on the PA:
 > 
 > 	ldil L'999424,%r19
 >         ldo 576(%r19),%r19
 > 	ldo -625(%r19),%r19
 > L$0109
 > 	comib,<>,n 0,%r19,L$0109
 > 	ldo -625(%r19),%r19
 > 
 > You get similar results on other architectures.  I was mystified by
 > the transformation of the decrement from 1 to 625.  Looking
 > at the output of the loop pass, I see that it has unrolled the loop:
[ ... ]
The documentation needs to be updated.

The compiler will estimate the size of a rolled and unrolled loop -- if the
unrolled loop is likely to be as small or smaller than the rolled loop, then
it will proceed to unroll the loop.

jeff



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]