[PATCH] Flag to enable IEEE-754 friendly FP optimizations

Mehdi Amini mehdi.amini at apple.com
Mon Jan 12 09:43:09 PST 2015


Hi,

Oh great some flags to help with floating point corner cases :)

A question: lib/Analysis/ConstantFolding.cpp contains this code that prevent folding NaN/Inf in InstCombine:

      /// We only fold functions with finite arguments. Folding NaN and inf is
      /// likely to be aborted with an exception anyway, and some host libms
      /// have known errors raising exceptions.
      if (Op->getValueAPF().isNaN() || Op->getValueAPF().isInfinity())
        return nullptr;

Can this be tied to KeepExceptions?

Thanks,

Mehdi




> On Jan 12, 2015, at 12:21 AM, Sergey Dmitrouk <sdmitrouk at accesssoftek.com> wrote:
> 
> Ping.
> 
> On Mon, Dec 22, 2014 at 11:36:10AM +0200, Sergey Dmitrouk wrote:
>> Hello Hal,
>> 
>> it took me some time to change the way it works, but now new changes also
>> cover some cases missed in the previous version.
>> 
>> After thinking a bit more I introduced two separate flags for exceptions
>> and rounding, as you suggested.  At the moment rounding flag just
>> disables folding, I'm not sure how to actually check that result of
>> operation doesn't depend on rounding mode.  This prevents early
>> optimization for something like "1.0 + 2.0", so might need adjustments
>> if there is a way to check whether rounding is important for particular
>> operation.
>> 
>> Using fast-math flags instead of function attributes didn't remove that
>> much flags as they are not used in code related to constant expression
>> folding.  In fact, I had to add one more "Strict" argument to be able to
>> prevent conversion to constant expressions, which results in losing
>> fast-math flags.
>> 
>> Please find updated set of patches in the attachment.
>> 
>> Thanks,
>> Sergey
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list