The beginning of the code for exp
looks something like:
const a = 369.3299304675746
const b = 6.755399441055744e15
function f(x::Float64)
z = muladd(x, a, b)
z -= b
end
Without --math-mode=fast
this gives the result 369.0
, with it it gives 369.3299304675746
. Looking at the generated code, in fast mode, it has simplified this code to x*a
:
julia> @code_llvm f(1.0)
...
%1 = fmul fast double %0, 0x40771547652B82FE
ret double %1
}
while it otherwise computes things as given:
julia> @code_llvm f(1.0)
...
%1 = fmul contract double %0, 0x40771547652B82FE
%2 = fadd contract double %1, 0x4338000000000000
%3 = fadd double %2, 0xC338000000000000
ret double %3
}
There can be an arbitrary error in the final result from such a change.