gcc loop unrolling problem ??

Matt Fago fago@caltech.edu
Thu Feb 12 15:46:00 GMT 2004


Robert Dewar wrote:
> Matt Fago wrote:
> 
>>> The number of unrollings depends on size of the loop and is bound to 8
>>> maximally.  Your loop has only single instruction so you get maximal
>>> unrolling.  See documentation of --param max-unrolled-insns,
>>> max-unroll-times and friends.
>>
>>
>> Is this also the case for loops with a constant number of iterations 
>> (my loops tend to be in powers of 3)? Should the documentation mention 
>> that the default value for max-unroll-times=8?
> 
> 
> I don't see why, this is really something quite internal to the
> optimizer. Obviously high values for unrolling are a bad idea that
> will slow the program down. The optimal caculation of unrolling
> is highly target dependent. I would guess many people increasing
> this parameter would be doing so for bogus reasons :-)

My code contains quite a few simple loops with 9 iterations. While I'm 
surprised that gcc doesn't attempt to completely unroll these, I do 
agree that doing so will not necessarily improve performance.

  - Matt



More information about the Gcc mailing list