4.5 #pragma unroll[(n)], #pragma unroll_completely

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 only has an effect with optimization level -O2 and higher.
When compiling with -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.
Non-ConfidentialPDF file icon PDF versionARM DUI0774E
Copyright © 2014-2016 ARM. All rights reserved.