Loop Unrolling

The benefits of loop unrolling are as follows:

The -unroll[n] (Linux* and Mac OS* X) or /Qunroll:[n] (Windows*) option controls how the Intel® compiler handles loop unrolling.

Refer to Applying Optimization Strategies for more information.

Linux and Mac OS X

Windows

Description

-unrolln

/Qunroll:n

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

(Linux and Mac OS X)

(Windows)

icpc -unroll4 a.cpp (Linux and Mac OS X)

icl /Qunroll:4 a.cpp (Windows)

Note iconNote

The compilers for IA-64 architecture recognizes only n = 0; any other value is ignored.

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.

Passing 0 as n disables loop unrolling; the following examples disables loop unrolling:

(Linux and Mac OS X)

(Windows)

icpc -unroll0 a.cpp (Linux and Mac OS X)

icl /Qunroll:0 a.cpp (Windows)

-funroll-all-loops

No equivalent

Instructs the compiler to unroll all loops even if the number of iterations is uncertain when the loop is entered.