Loop Unrolling Support

The UNROLL directive tells the compiler how many times to unroll a counted loop.

The syntax for this directive is:

CDEC$ UNROLL or !DEC$ UNROLL

CDEC$ UNROLL [n] or !DEC$ UNROLL [n]

CDEC$ NOUNROLL or !DEC$ NOUNROLL

where n is an integer constant. The range of n is 0 through 255.

The UNROLL directive must precede the do statement for each do loop it affects.

If n is specified, the optimizer unrolls the loop n times. If n is omitted or if it is outside the allowed range, the optimizer assigns the number of times to unroll the loop.

The UNROLL directive overrides any setting of loop unrolling from the command line.

Currently, the directive can be applied only for the innermost loop nest. If applied to the outer loop nests, it is ignored. The compiler generates correct code by comparing n and the loop count.

UNROLL

CDEC$ UNROLL(4)
do i = 1, m
b(i) = a(i) + 1
d(i) = c(i) + 1
enddo