Force the compiler to align loop code

Caution: Excessive code alignment may increase application binary size and decrease performance.
Static analysis shows the loop may benefit from code alignment. To fix: Force the compiler to align the loop to a power-of-two byte boundary using a compiler directive for finer-grained control: !DIR$ CODE_ALIGN [:n]

Example

!DIR$ CODE_ALIGN :64
do i = 1, n, 1
...

Align outer loop to 64-byte boundary

!DIR$ CODE_ALIGN :64
do i = 1, n, 1
    do j = 1, m, 1
        a(i) = a(i) * (b(i) + c(j))
    enddo
enddo

You may also use the following compiler option:

Windows* OSLinux* OS and macOS*
/Qalign-loops[:n]-falign-loops[=n]

where n = a power of 2 betwen 1 and 4096, such as 1, 2, 4, 8, 16, 32, etc. n = 1 performs no alignment. If n is not present, the compiler uses an alignment of 16 bytes. Suggestion: Try 16 and 32 first.

/Qalign-loops- and -fno-align-loops, the default compiler option, disables special loop alignment.

Read More