[LLVMdev] Presenting Unsafe Math Flag to Optimizer
Morten Ofstad
morten at hue.no
Thu Jan 14 06:07:58 PST 2010
> There are three options, that you mentioned off-line:
>
> A) Caller wins
> This could result in something the programmer didn't expect, possibly
> resulting in an incorrect answer.
>
> B) Don't inline
> We potentially miss important optimizations.
>
> C) Safety first
> The programmer could get code they didn't expect, but at least it won't
> result in an "incorrect" answer. I.e., it will be correct modulo LLVM
> bugs, but lacking any unsafe transforms they were expecting.
>From having worked extensively on FP code, I would prefer option B -- often
the most important property is that two calls to the same function with the
same parameters produce the same result, you don't want the function to
produce different results if it has been inlined or not even if the inlined
result is more 'correct' (which would be the case with C).
One example of the kind of problems you can get into is if you have a test
to see which side of a plane a point is on and it produces different results
from two different calls with the same point and the same plane.
- Morten
More information about the llvm-dev
mailing list