-Cu: Loop Unrolling

Group

OPTIMIZATIONS

Scope

Function

Syntax
-Cu[=i<number>] 
Arguments

<number>: number of iterations for unrolling, between 0 and 1024

Default

None

Defines

None

Pragmas

#pragma LOOP_UNROLL: Force Loop Unrolling

#pragma NO_LOOP_UNROLL: Disable Loop Unrolling

Description

Enables loop unrolling with the following restrictions:

Examples
Listing: for Loop


-Cu int i, j;

j = 0;

for (i=0; i<3; i++) {

  j += i;

}

With the -Cu compiler option given, the Compiler issues an information message 'Unrolling loop' and transforms this loop as shown in the following listing.

Listing: for Loop


j += 1;
j += 2;

i  = 3;

The Compiler also transforms some special loops, i.e., loops with a constant condition or loops with only one pass:

Listing: Example for Loop with a Constant Condition


for (i=1; i>3; i++) {
  j += i;

}

The Compiler issues an information message 'Constant condition found, removing loop' and transforms the loop into a simple assignment, because the loop body is never executed:

i=1;

Listing: Example for Loop with Only One Pass


for (i=1; i<2; i++) {
  j += i;

}

Because the loop body is executed only once, the Compiler issues a warning 'Unrolling loop' and transforms the for loop into:

j += 1;

i  = 2;