10.101 #pragma unroll_completely

This pragma instructs the compiler to completely unroll a loop. It has an effect only if the compiler can determine the number of iterations the loop has.

Note

Both vectorized and nonvectorized loops can be unrolled using #pragma unroll_completely. That is, #pragma unroll_completely applies to both --no_vectorize and --vectorize.

Usage

This pragma is only applicable if you are compiling with -O3 -Otime. When compiling with -O3-Otime, the compiler automatically unrolls loops where it is beneficial to do so. You can use this pragma to ask the compiler to completely unroll a loop that has not automatically been unrolled completely.

Note

Use this #pragma only when you have evidence, for example from --diag_warning=optimizations, that the compiler is not unrolling loops optimally by itself.

You cannot determine whether this pragma is having any effect unless you compile with --diag_warning=optimizations or examine the generated assembly code, or both.

Restrictions

This pragma can only take effect when you compile with -O3 -Otime. Even then, the use of 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.

#pragma unroll_completely can only be used immediately before a for loop, a while loop, or a do ... while loop.

Using #pragma unroll_completely on an outer loop can prevent vectorization. On the other hand, using #pragma unroll_completely on an inner loop might help in some cases.

Related concepts
5.7 Loop unrolling in C code
Related reference
10.100 #pragma unroll [(n)]
8.61 --diag_warning=tag[,tag,...]
8.138 -Onum
8.142 -Otime
8.189 --vectorize, --no_vectorize
Non-Confidential PDF file icon PDF version ARM DUI0472J
Copyright © 2010-2013 ARM. All rights reserved.