Indicates to the compiler to unroll or not to unroll a counted loop.
- The unrolling factor representing the number of times to unroll a loop; it must be an integer constant from 0 through 255.
[n]pragma tells the compiler how many times to unroll a counted loop.
unrollpragma must precede the
forstatement for each
forloop it affects. If
nis specified, the optimizer unrolls the loop
nis omitted or if it is outside the allowed range, the optimizer assigns the number of times to unroll the loop.
This pragma is supported only when option
O3is set. The
unrollpragma overrides any setting of loop unrolling from the command line.
The pragma can be applied for the innermost loop nest as well as for the outer loop nest. If applied to outer loop nests, the current implementation supports complete outer loop unrolling. The loops inside the loop nest are either not unrolled at all or completely unrolled. The compiler generates correct code by comparing
nand the loop count.
When unrolling a loop increases register pressure and code size it may be necessary to prevent unrolling of a loop. In such cases, use the
nounrollpragma instructs the compiler not to unroll a specified loop.
Example: Using the
unrollpragma for innermost loop unrolling