Loop Unrolling

The benefits of loop unrolling are as follows:

A potential limitation is that excessive unrolling, or unrolling of very large loops, can lead to increased code size. For more information on how to optimize with the -unroll[n] (Linux*) or /Qunroll[n] (Windows*) option, refer to the Intel® Pentium® 4 and Intel® Xeon™ Processor Optimization Reference Manual.

The -unroll[n] (Linux*) or /Qunroll[n] (Windows*) option controls how the Intel® compiler handles loop unrolling. The following table summarizes how to use this option:

Windows

Linux

Description

/Qunrolln

Synonym:
/unroll[:
n]

-unrolln

Specifies the maximum number of times you want to unroll a loop. The following examples unrolls a loop at most four times:

ifort -unroll4 a.f (Linux)

ifort /Qunroll4 a.f (Windows)

Note

The Itanium® compiler currently recognizes only n = 0; any other value is ignored.

/Qunroll

-unroll

Omitting a value for n lets the compiler decide whether to perform unrolling or not. This is the default; the compiler uses default heuristics or defines n.

/Qunroll0

-unroll0

Disables the loop unroller. To disable loop unrolling, specify n as 0. The following examples disables loop unrolling:

ifort -unroll0 a.f (Linux)

ifort /Qunroll0 a.f (Windows)

For more information about the option behaviors listed above, see the following topic: