[LLVMdev] Presenting Unsafe Math Flag to Optimizer
wendling at apple.com
Thu Jan 14 11:04:45 PST 2010
On Jan 14, 2010, at 6:07 AM, Morten Ofstad wrote:
>> 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.
Good point. :-) Though it looks like we would bypass this and go with flags on the individual instructions. Do you have any insight into Chris's response?
More information about the llvm-dev