[PATCH] [APFloat] x-NaN needs to flip sign of NaN

Steve (Numerics) Canon scanon at apple.com
Sat Jun 7 23:44:24 PDT 2014


On Jun 7, 2014, at 11:25 PM, Alp Toker <alp at nuanti.com> wrote:

> On 08/06/2014 09:18, Steve (Numerics) Canon wrote:
>> This is simple enough for review-after-commit, but I don't often work on llvm, so I thought it best to send for review.
>> 
>> This patch fixes http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-June/037388.html; it turned out to be caused by APFloat not negating the sign of the NaN when producing the result of (0 – NaN).  I made it flip the sign for x – NaN where x is any number.  This isn't strictly required, but is allowed by IEEE-754, and was the minimal source change to get the needed behavior for the 0 – NaN case.
>> 
>> I have no idea how to write a test case for this bug; APFloat seems to be, ahem, "sparsely tested" at present, so there isn't much stylistic precedent.
> 
> Hi Steve,
> 
> This is one of those (rare) cases where a unit test is appropriate. Could you take a look at unittests/ADT/APFloatTest.cpp?
> 
> Alp.

Ah!  Thanks for the tip.

Now with tests:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: APFloat-negate.patch
Type: application/octet-stream
Size: 9550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140607/85e2fc2f/attachment.obj>


More information about the llvm-commits mailing list