Syntax:
pragma Loop_Optimize (OPTIMIZATION_HINT {, OPTIMIZATION_HINT}); OPTIMIZATION_HINT ::= Ivdep | No_Unroll | Unroll | No_Vector | Vector
This pragma must appear immediately within a loop statement. It allows the programmer to specify optimization hints for the enclosing loop. The hints are not mutually exclusive and can be freely mixed, but not all combinations will yield a sensible outcome.
There are five supported optimization hints for a loop:
The programmer asserts that there are no loop-carried dependencies which would prevent consecutive iterations of the loop from being executed simultaneously.
The loop must not be unrolled. This is a strong hint: the compiler will not unroll a loop marked with this hint.
The loop should be unrolled. This is a weak hint: the compiler will try to apply unrolling to this loop preferably to other optimizations, notably vectorization, but there is no guarantee that the loop will be unrolled.
The loop must not be vectorized. This is a strong hint: the compiler will not vectorize a loop marked with this hint.
The loop should be vectorized. This is a weak hint: the compiler will try to apply vectorization to this loop preferably to other optimizations, notably unrolling, but there is no guarantee that the loop will be vectorized.
These hints do not remove the need to pass the appropriate switches to the compiler in order to enable the relevant optimizations, that is to say ‘-funroll-loops’ for unrolling and ‘-ftree-vectorize’ for vectorization.