Instructs the compiler to unroll a loop by n iterations.
Syntax
#pragma unroll
#pragma unroll_completely
#pragma unroll n
#pragma unroll(n)
Where:
n
is an optional value indicating the number of iterations
to unroll.
Default
If you do not specify a value for n, the compiler attempts to fully unroll
the loop. The compiler can only fully unroll loops where it can determine the number
of iterations.
#pragma unroll_completely will not
unroll a loop if the number of iterations is not known at compile time.
Usage
This pragma is supported at the -Os, -Oz, -O2, -O3, -Ofast, and -Omax optimization levels. It is not
supported at the -O0 or
-O1 optimization
levels.
When compiling at -O3, the compiler
automatically unrolls loops where it is beneficial to do so. This pragma can be used
to ask the compiler to unroll a loop that has not been unrolled automatically.
#pragma unroll[(n)] can be used immediately before a for loop, a while loop, or a do ... while loop.
Restrictions
This pragma is a request to the compiler
to unroll a loop that has not been unrolled automatically. It does not guarantee
that the loop is unrolled.
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.