[LLVMdev] Presenting Unsafe Math Flag to Optimizer

Bill Wendling wendling at apple.com
Wed Jan 13 17:12:00 PST 2010

On Jan 13, 2010, at 4:50 PM, Devang Patel wrote:

> On Wed, Jan 13, 2010 at 4:20 PM, Bill Wendling <wendling at apple.com> wrote:
>> Hi all,
>> A quick question:
>> The current implementation of the "allow unsafe math" option is to specify it via the TargetOptions object. However, this prevents the target-independent optimizer from using it. Are there any opinions (ha!) on how this could be achieved in a nice clean manner which doesn't require using the TargetOptions object in the optimizer?
> function attribute.

Not a bad idea. However, how should it behave during inlining for LTO? (I really don't know the answer to this.)

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.


More information about the llvm-dev mailing list