Re: Loop unrolling

Ian Collins wrote:

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.

We have looked at a lot of customer embedded system code related
to loop unrolling and eventually concluded that best thing that we
could do in our compilers was to compile the code as written.

Application code usually was very clear and almost always right
in their timing choice of straight line vs loop implementation. Rolling
up straight line code and unrolling loops more often than not
interfered with a conscience choice a developer made.


Walter Banks
Byte Craft Limited
Tel. (519) 888-6911