[PATCH][X86] Unsafe copysign xform in DAGCombiner

Cameron McInally via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 9 11:49:47 PDT 2016


On Fri, Sep 9, 2016 at 1:52 PM, Matt Arsenault <arsenm2 at gmail.com> wrote:
>
>> On Sep 9, 2016, at 10:33, Friedman, Eli via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>>
>> On 9/9/2016 9:25 AM, Cameron McInally via llvm-commits wrote:
>>> Hey guys,
>>>
>>> There's a copysign xform in the DAGCombiner that replaces safe FP code
>>> with unsafe code. Attached is a patch to guard this xform.
>>>
>>> The issue here (see test case) is the first copysign is removed before
>>> the cvt is performed. If the input to the cvt is unordered, it will
>>> raise an exception. The purpose of the first copysign is to create a
>>> safe value (i.e. 1.0 or -1.0) to feed the cvt.
>>
>> By "exception", you mean a floating-point exception?  LLVM generally assumes that floating-point exceptions are masked and ignored; see https://llvm.org/bugs/show_bug.cgi?id=8100, https://llvm.org/bugs/show_bug.cgi?id=18673, etc.  I think there's also been some discussion on llvmdev recently.
>>
>> -Eli
>
>
> There is a TLI.hasFloatingPointExceptions you can check
>
> -Matt

Hey Matt and Eli,

Are you guys suggesting checking both flags before disabling the
xform? Or something else, like not pursuing the patch?

I choose UnsafeFPMath from the prior art in DAGCombiner.cpp. It looks
like the other uses mostly cover numerical differences though. I
mistakenly assumed that UnsafeFPMath covered exceptions too.

An IEEE conformance flag would sure be nice... ;)

-Cam


More information about the llvm-commits mailing list