Product Version: Intel(R) Visual Fortran Compiler XE 15.0.0.070
Cause:
When using Intel Visual Fortran Compiler's optimization and vectorization report options -O2 -Qvec-report2 -Qopt-report:2 the vectorization report generated states that loop was not vectorized since vector dependence prevents vectorization.
Example:
An example below will generate the following remark in optimization report:
integer function foo(a, n) implicit none integer, intent(in) :: n real, intent(inout) :: a(n) real :: max integer :: inx, i max = a(0) do i=1,n if (max < a(i)) then max = a(i) inx = i*i endif end do foo = inx end function
Report from: Vector optimizations [vec]
LOOP BEGIN at f15344.f90(9,5)
remark #15344: loop was not vectorized: vector dependence prevents vectorization. First dependence is shown below. Use level 5 report for details [ f15344.f90(12,13) ]
remark #15346: vector dependence: assumed ANTI dependence between line 10 and line 10 [ f15344.f90(12,13) ]
LOOP END
Resolution:
Rewriting the code as in the following example will resolve vector dependence and the loop will be vectorized
integer function foo(a, n) implicit none integer, intent(in) :: n real, intent(inout) :: a(n) real :: max integer :: inx, i max = a(0) do i=1,n if (max < a(i)) then max = a(i) inx = i endif end do foo = inx*inx end function
See also:
Requirements for Vectorizable Loops
Vectorization and Optimization Reports
Back to the list of vectorization diagnostics for Intel Fortran