[LLVMdev] Presenting Unsafe Math Flag to Optimizer
Chris Lattner
clattner at apple.com
Thu Jan 14 09:45:26 PST 2010
On Jan 14, 2010, at 2:01 AM, Duncan Sands wrote:
> Hi Bill,
>
>> 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?
>
> a flag on each floating point operation, saying whether it does
> "exact" math or
> not?
Yes, the right approach for this is to add flags to each fp operations
just like the NUW/NSW bits on integer ops. We want the ability to
represent the C99 pragmas which are scoped more tightly than a
function body.
This is actually really easy to do, the big issue is defining the
'bits' that we want to carry on each operation. For example, I think
it would be reasonable to have an "assume finite" bit (saying no
nan's / inf), it would also be useful to know you can do reassociation
etc, useful to know that you don't care about signed zero, etc.
I don't have enough expertise to propose exactly how this should work.
-Chris
More information about the llvm-dev
mailing list