Re: Loop unrolling

Tim Frink wrote:

what are typical heuristics for loop unrolling, i.e. which constraints
must be satisfied to have a compiler perform unrolling on a particular

I assume that the loop must not exceed a particular size to avoid a
code size explosion. But are there any other heuristics?

They will be specific to the compiler and loops don't have to be
completely unrolled. For example a loop of 100 may be expanded to a
loop of 20 blocks of 5 repeats.

Some compilers provide a means for tuning loop unrolling as a
space/performance trade off.

Ian Collins.