The following code:
program spectest integer NITER parameter (NITER = 1000) real a(NITER), b(NITER), c(NITER) CHARACTER*16 out integer i a = 1 b = 1 c = 1 c(100) = 0 i = ieee_flags('set', 'exception', 'all', out) ! !DIR$ NOUNROLL do i = 1 , NITER if (c(i) .ne. 0) then a(i) = b(i) / c(i) endif enddo print *, a(101) end
when compiled with ifort 18.0.5 and -fp-speculation=strict it disables vectorization of the division loop:
LOOP BEGIN at spectest2.f90(17,10)
remark #15326: loop was not vectorized: implied FP exception model prevents vectorization. Consider changing compiler flags and/or directives in the source to enable fast FP model and to mask FP exceptions [ spectest2.f90(19,22) ]
At first this seems expected - I could assume that speculation is somehow linked with the vectorization of the loop.
What seems strange though is that the same code compiled with -fp-speculation=safe allows vectorization of the loop and an FPE is not raised.
Therefore, the compiler has managed under the "safe" setting to get away with a vectorized plus non-speculative code.
Whatever that code is why it cannot be generated also for the case of -fp-speculation=strict?
I am trying to understand the speculation=safe vs strict settings. The only information that I could find in the compiler manuals is the following:
strict : Tells the compiler to disable speculation on floating-point operations.
safe: Tells the compiler to disable speculation if there is a possibility that the speculation may cause a floating-point exception.
However this does not add up to the behavior I am observing for these options.
I would really appreciate If somebody could help clarify these options or point me to some more detailed documentation.