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: #pragma code_align (n)

Example

...
#pragma code_align 32
    for (j = 0; j < m; j++)
...

Align inner loop to 32-byte boundary

for (i = 0; i < n; i++)
{
#pragma code_align 32
    for (j = 0; j < m; j++)
    {
        a[i] *= b[i] + c[j];
    }
}

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