Loop Unrolling

You can unroll loops and specify the maximum number of times you want the compiler to do so.

How to Enable Loop Unrolling

You use the -unroll[n] option to unroll loops. n  determines the maximum number of times for the unrolling operation. This applies only to loops that the compiler determines should be unrolled. Omit n to let the compiler decide whether to perform unrolling or not.

The following example unrolls a loop at most four times:

IA-32 Systems: prompt>icc -unroll4 a.c

When specifying high values to unroll loops, be aware that your application may exhaust certain resources, such as registers, that can slow program performance. You should consider timing your application (see Timing Your Application) if you specify high values to unroll loops.

How to Disable Loop Unrolling

Disable loop unrolling by setting n to 0. The following example disables loop unrolling:

IA-32 Systems: prompt>icc -unroll0 a.c