Product Version: Intel® Fortran Compiler 15.0 and above
Cause:
When a loop contains a conditional statement which controls the assignment of a scalar value AND the scalar value is referenced AFTER the loop exits. The vectorization report generated using Intel® Fortran Compiler's optimization and vectorization report options includes non-vectorized loop instance:
Windows* OS: /O2 /Qopt-report:2 /Qopt-report-phase:vec
Linux OS or OS X: -O2 -qopt-report2 -qopt-report-phase=vec
Example:
An example below will generate the following remark in optimization report:
$ ifort -c -O2 -qopt-report2 -qopenmp-simd -qopt-report-file=stderr -qopt-report-phase=vec f13379.f90
When using Intel Fortran Compiler version 16.0 the following remark is generated:
LOOP BEGIN at f13379.f90(8,3)
remark #15336: simd loop was not vectorized: conditional assignment to a scalar [ f13379.f90(10,8) ]
remark #13379: loop was not vectorized with "simd"
LOOP END
When using Intel Fortran Compiler version 17.0 the following remark is generated:
LOOP BEGIN at f15336.f90(12,3)
remark #15316: simd loop was not vectorized: scalar assignment in simd loop is prohibited, consider private, lastprivate or reduction clauses f15336.f90(10,6)
remark #15552: loop was not vectorized with "simd"
LOOP END
Resolution:
Using !$omp simd lastprivate(x) instead of !$omp simd will have x initialized for each subroutine in executable code.
Example
$ ifort -c -O2 -qopt-report2 -qopenmp-simd -qopt-report-file=stderr -qopt-report-phase=vec f13379.f90
Begin optimization report for: F13379
Report from: Vector optimizations [vec]
LOOP BEGIN at f13379.f90(10,3)
remark #15301: OpenMP SIMD LOOP WAS VECTORIZED
LOOP END
See also:
Requirements for Vectorizable Loops
Vectorization and Optimization Reports