Review these guidelines and restrictions, see code examples in further topics, and check them against your code to eliminate ambiguities that prevent the compiler from achieving optimal vectorization.
Guidelines for loop bodies:
Use straight-line code (a single basic block)
Use vector data only; that is, arrays and invariant expressions on the right hand side of assignments. Array references can appear on the left hand side of assignments.
Use only assignment statements
Avoid the following in loop bodies:
Function calls
Unvectorizable operations
Mixing vectorizable types in the same loop
Data-dependent loop exit conditions
Loop unrolling (compiler does it)
To make your code vectorizable, you will often need to make some changes to your loops. However, you should make only the changes needed to enable vectorization and no others. In particular, you should avoid these common changes:
Do not unroll your loops, the compiler does this automatically.
Do not decompose one loop with several statements in the body into several single-statement loops.