[PATCH] D87835: [APFloat] prevent NaN morphing into Inf on conversion (PR43907)

John McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 20:51:11 PDT 2020


rjmccall added a comment.

In D87835#2280070 <https://reviews.llvm.org/D87835#2280070>, @spatel wrote:

> In D87835#2279926 <https://reviews.llvm.org/D87835#2279926>, @rjmccall wrote:
>
>> So I think the only quibble here is whether it's okay for this to silently produce a qNaN when it might've started with an sNaN.  And arguably the current contract of APFloat is to perform operations as if FP exceptions were disabled, and we'll need a slightly different interface if we want to model exceptions properly.  So I think this might just be fine as-is.
>
> If we started with a qNaN, then we can't hit the bug, right? Ie, if the MSB of the significand is set, there's no way we could shift that out. If that's correct, then we could just always set the bottom bit? That way sNaN remains sNaN even if lose the payload.
>
> Or maybe that's not true in the case of the x87 or other special formats?

I think it's generally true, even on x87.

If we're going to try to stick with an sNaN, I think we should set the second bit in the significand, which will then be stable across formats for the same reason that the qNaN bit is.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87835/new/

https://reviews.llvm.org/D87835



More information about the llvm-commits mailing list