Diagnostic 15344: Loop was not vectorized: vector dependence prevents vectorization

Product Version:Intel® Fortran Compiler 15.0 and above

Cause:

When using Intel® Fortran Compiler's optimization and vectorization report options /O2 /Qopt-report:2 /Qopt-report-phase:vecthe vectorization report generated states that loop was not vectorized due to vector dependence which 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

ifort -c /O2 /Qopt-report:2 /Qopt-report-phase:vec /Qopt-report-file:stdout f15344.f90

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 11   [ 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 Essentials

Vectorization and Optimization Reports

Back to the list of vectorization diagnostics for Intel® Fortran

 

 

 

For more complete information about compiler optimizations, see our Optimization Notice.