Vectorizable Data References

For any data reference, either as an array element or pointer reference (see definitions below), take care to ensure that there are no potential dependence or alias constraints preventing vectorization; intuitively, an expression in one iteration must not depend on the value computed in a previous iteration and pointer variables must provably point to distinct locations.

Arrays

Vectorizable data in a loop may be expressed as uses of array elements, provided that the array references are unit-stride or loop-invariant. Non-unit stride references are not vectorized by default; the vector pragma can be used to override this.

Pointers

Vectorizable data can also be expressed using pointers, subject to the same constraints as uses of array elements: you cannot vectorize references that are non-unit stride or loop invariant.

Invariants

Vectorizable data can also include loop invariant references on the right hand inside an expression, either as variables or numeric constants. The loop in the following example will vectorize.

 

Vectorizable Loop Invariant Reference

SUBROUTINE FOO (A, B, C, N)
DIMENSION A(N),B(N),C(N)
INTEGER N, I, J
J = 5;
DO I=1, N
A(I) = B(I) * 3.14 + C(J)
ENDDO
RETURN
END

If vectorizable REAL data is provably aligned, the compiler will generate aligned instructions. This is the case for locally declared data. Where data alignment is not known, unaligned references will be used unless a directive is used to override this. The compiler supports IVDEP directive which instructs the compiler to ignore assumed vector dependences. Use this directive when you know that the assumed loop dependences are safe to ignore. For details on the IVDEP directive, see Appendix A in the Intel® Fortran Programmer's Reference.