Diagnostic 15534: Loop was not vectorized: loop contains arithmetic if or computed goto.

By Devorah Hayman, Published: 10/29/2014, Last Updated: 04/04/2016

Product Version: Intel(R) Visual Fortran Compiler XE 15.0 or a later version

Cause:

The vectorization report generated when using Visual Fortran Compiler's optimization options ( /O3 or /O2  /Qopt-report:2 ) states that loop was not vectorized since loop contains GOTO statement.

Example:

An example below will generate the following remark in optimization report:

subroutine foo(a, b, n) 
      implicit none 
      integer, intent(in)    :: n 
      real,    intent(inout) :: a(n) 
      integer, intent(in)    :: b(n) 
      integer:: i 
        
      do 500 i=1,n 
        goto (100,200,300,400,100,200) b(i) 
100     a(i) = 1. + a(i)**4 
        go to 500  
200     a(i) = 1. + log(a(i))
        go to 500
300     a(i) = 2. * a(i) 
        go to 500
400     a(i) = 1. - sin(a(i))**2
500   continue 

end subroutine foo

$ ifort -c -xavx f15534a.f90 -qopt-report-file=stderr -qopt-report-phase=vec

Report from: Vector optimizations [vec]

Non-optimizable loops:

LOOP BEGIN at f15534a.f90(8,10)

   remark #15534: loop was not vectorized: loop contains arithmetic if or computed goto. Consider using if-then-else statement.    [ f15534a.f90(9,9) ]

LOOP END

Resolution:

Complex flow control can prevent vectorization; rewriting the code using IF statements instead of a computed GO TO will get this loop vectorized:”

subroutine foo(a, b, n) 
      implicit none 
      integer, intent(in)    :: n 
      real,    intent(inout) :: a(n) 
      integer, intent(in)    :: b(n) 
      integer:: i 
        
      do i=1,n 
        if(b(i).eq.1 .or. b(I).eq.5) a(i) = 1. + a(i)**4 
        if(b(i).eq.2 .or. b(i).eq.6) a(i) = 1. + log(a(i))
        if(b(i).eq.3)                a(i) = 2. * a(i)
        if(b(i).eq.4)                a(i) = 1. - sin(a(i))**2           
      end do 

end subroutine foo

$ ifort -c -xavx f15534b.f90 -qopt-report-file=stderr -qopt-report-phase=vec

LOOP BEGIN at f15534b.f90(8,7)

<Peeled loop for vectorization>

LOOP END

LOOP BEGIN at f15534b.f90(8,7)

   remark #15300: LOOP WAS VECTORIZED

LOOP END

LOOP BEGIN at f15534b.f90(8,7)

<Remainder loop for vectorization>

LOOP END

 

See also:

Requirements for Vectorizable Loops

Vectorization Essentials

Vectorization and Optimization Reports

Back to the list of vectorization diagnostics for Intel® Fortran

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804