1. A loop contains a conditional statement
2. The conditional statement is controlling the assignment of a scalar value.
3. The logic of the assignment is such that the value of the scalar at the end of execution of the loop depends on the loop executing iterations strictly in-order AND
4. the scalar value is referenced AFTER the loop exits.
Below is an example:
subroutine f15038( a, b, n ) implicit none integer :: a(n), b(n), n integer :: i, x=10 !dir$ simd do i=1,n if( a(i) > 0 ) then x = i !...here is the conditional assignment end if b(i) = x end do !... reference the scalar outside of the loop write(*,*) "last value of x: ", x end subroutine f15038
ifort -c -vec-report2 f15038.f90
f15038.f90(10): (col. 6) remark: loop was not vectorized: conditional assignment to a scalar
f15038.f90(8): (col. 1) warning #13379: loop was not vectorized with "simd"
1. The reference of the scalar after the loop requires that the value coming out of the loop is "correct", meaning that the loop iterations were executed strictly in-order and sequentially. IF the scalar is NOT referenced outside of the loop, the compiler can can vectorize this loop since the order of that the iterations are evaluated does not matter - without reference outside the loop the final value of the scalar does not matter since it is no longer referenced.
subroutine f15038( a, b, n ) implicit none integer :: a(n), b(n), n integer :: i, x=10 !dir$ simd do i=1,n if( a(i) > 0 ) then x = i !...here is the conditional assignment end if b(i) = x end do !... no reference to scalar X outside of the loop !... removed the WRITE statment for X end subroutine f15038
> ifort -c -vec-report2 f15038.f90
f15038.f90(8): (col. 1) remark: SIMD LOOP WAS VECTORIZED
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