loopUnroll Optimization Option (AIX)

Syntax: Default:
opt(loopUnroll[, yes])
opt(loopUnroll, number)
opt(loopUnroll, no)
opt(loopUnroll, no)

This option controls whether inner loops in the program are unrolled.

By default, inner loops in the code are not unrolled.

When opt(loopUnroll, number) is specified, inner loops are unrolled by a factor of number.  The bodies of inner loops are duplicated number-1 times, creating a loop with number original bodies.  The loop control may be modified in some cases to avoid unnecessary branching.  The maximum value for number is 8.

@prodname may perform automatic unrolling of inner loops by a factor of up to 16 at an optimization level of 2 or higher (for example, when you specify opt(level, 3)).  This optimization will be disabled, however, if you specify opt(loopUnroll, no).  The opt(size) option also suppresses loop unrolling.

Specifying opt(loopUnroll, yes) is equivalent to specifying opt(loopUnroll, 4). 

You can also control loop unrolling by using #pragma options [no]unroll and unroll=number. The pragma overrides the configuration file option.

Example

In the following example, loop control is not modified:

while (*s != 0)
{
	*p++ = *s++;
}

Unrolling this by a factor of 2 results in code equivalent to the following code:

while (*s)
{
	*p++ = *s++;
	if (*s == 0) break;
	*p++ = *s++;
}

In the following example, loop control is modified:

for (i=0; i<n; i++) {
	a[i] = b[i] * c[i];
}

Unrolling by a factor of 3 results in code equivalent to the following code:

if (n>=0) {
       if (n<2) {
           a[0] = b[0] * c[0];
           i = 1;
           if (n>0) {
               a[1] = b[1] * c[1];
               i = 2;
           }
       }
       for (; i<n-2; i+=3) {
           a[i] = b[i] * c[i];
           a[i+1] = b[i+1] * c[i+1];
           a[i+2] = b[i+2] * c[i+2];
       }
}


Incremental C++ Build
Configuration Files


Set Build Options
Build
Optimize Your Application
Debug Optimized Code


Optimization Options
Optimization Options