[PATCH] PR16258 - fadd with undef not folded

Stephen Canon scanon at apple.com
Mon Jun 10 09:13:22 PDT 2013


On Jun 10, 2013, at 9:02 AM, Duncan Sands <baldrick at free.fr> wrote:

> Hi Stephen,
> 
> On 10/06/13 17:53, Stephen Canon wrote:
>> On Jun 10, 2013, at 8:50 AM, Duncan Sands <baldrick at free.fr
>> <mailto:baldrick at free.fr>> wrote:
>> 
>>>>> If undef can't be achieved, it might still be possible to fold to a NaN
>>>>> or some other special value.
>>>> 
>>>> Folding to NaN sounds workable to me.
>>> 
>>> So if Y is a well-chosen NaN (or will any NaN do?) then fadd X, Y will always
>>> be equal to Y?  Does the same go for fmul, fsub and fdiv?
>> 
>> If Y is any NaN, then the result of any IEEE-754 basic operation (add, sub, mul,
>> div, sqrt, ... ) will be NaN (it will not “be equal to Y", because NaNs compare
>> unequal to everything).
> 
> by equal I meant: the same bit pattern.

There’s some subtlety here w.r.t. bit patterns (the result of OP x, y when x and y are both NaNs will be a NaN, but the exact bit pattern isn’t pinned down and in practice depends on the phase of the moon).  However, NaN bit patterns are essentially an implementation detail; I think there’s enough room here that we can reasonably fold undef operations to NaN (and as a programmer, I would certainly be very happy to get NaN for undef; NaN is a big obvious smoking gun).

- Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130610/9dee44d9/attachment.html>


More information about the llvm-commits mailing list