I have a program that gives a floating point exception (when compiled with -fpe0) unless a particular routine is compiled with -IPF_fp_speculationsafe. I found this particular option to be critical by trying all the restrictions of the -mp option one by one.
If the program is compiled with -fpe3 so that FP exceptions are not trapped, it runs ok and no Infs or NaNs appear in the final result.
My understanding of speculation is pretty minimal, but I thought it involved things like executing code on a branch that may not be taken in the end. Presumably FP exceptions on such branches get dropped.
The exception seems to occur in a loop
ttdb1(:,k+1) = exp(hm1ez*min(fifty,abcff(1)*ud(:,k+1)))
ttub1(:,k) = exp(hm1ez*min(fifty,abcff(1)*ur(:,k)))
ttd(:,k+1) = ttdb1(:,k+1)*(1.-ao3(:,k+1))
ttu(:,k) = ttub1(:,k)*(1.-ao3(:,lp1+k))
Adding too many diagnostics either removes the problem or moves it somewhere else but as far as I can tell all the input values are sensible.
My question is really whether this points to a problem with my code or with the compiler. The fact that a speculationsafe option exists suggests there must be cases where it is unsafe. Does anyone have a simple example of this to help me understand what's happening.