Product Version: Intel® Visual Fortran Compiler XE 15.0 or a later version
Cause:
The vectorization report generated when using Visual Fortran Compiler's flags and optimization options (/O2 /fpe:0 /Qopt-report:2) states that loop was not vectorized due to floating-point exception handling .
Example:
An example below will generate the following remark in optimization report:
subroutine foo (a, l, n)
implicit none
integer, intent(in) :: n
double precision, intent(inout) :: a(n)
integer :: l(n)
integer :: i
do i=1,n
l(i) = mod(a(i), 1.0)
end do
end subroutine foo
ifort -c /O2 /fpe:0 /Qopt-report:2 /Qopt-report-phase:vec /Qopt-report-file:stdout f15537.f90
(ifort -c -O2 -fpe=0 -qopt-report2 f15537.f90 for Linux)
Begin optimization report for: FOO
Report from: Vector optimizations [vec]
LOOP BEGIN at f15537.f90(8,8)
remark #15537: loop was not vectorized: implied FP exception model prevents usage of SVML library needed for truncation or integer divide/remainder. Consider changing compiler flags and/or directives in the source to enable fast FP model and to mask FP exceptions [ f15537.f90(9,19) ]
LOOP END
Resolution:
Masking FP exceptions /fpe:1 and setting a threshold for the vectorization of loops to 0 /Qvec-threshold:0 will get the loop vectorized:
ifort -c /O2 /fpe:1 /Qvec-threshold:0 /Qopt-report:2 /Qopt-report-phase:vec /Qopt-report-file:stdout f15537.f90
(ifort -c -O2 -fpe=1 -vec-threshold=0 -qopt-report2 f15537.f90 for Linux)
LOOP BEGIN f15537.f90(8,8)
remark #15300: LOOP WAS VECTORIZED
LOOP END
See also:
Requirements for Vectorizable Loops
Vectorization and Optimization Reports