[PATCH] D87835: [APFloat] prevent NaN morphing into Inf on conversion (PR43907)
John McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 18 11:26:37 PDT 2020
rjmccall added inline comments.
================
Comment at: llvm/lib/Support/APFloat.cpp:2248
+ // bit in the significand must be set (otherwise it is Inf).
+ // Set the 1st bit after the quiet bit to preserve SNaN.
+ // TODO: We should check if the shifting loses any bits above here and set
----------------
Probably best to clarify:
> This can only happen with sNaN, so set the 1st bit after the quiet bit so that we still have an sNaN.
================
Comment at: llvm/lib/Support/APFloat.cpp:2251
+ // losesInfo.
+ // TODO: Would it be better to set quiet and return opInvalidOp?
+ if (APInt::tcIsZero(significandParts(), newPartCount)) {
----------------
That might be more reasonable than manufacturing an artificial sNaN, yeah. But if we're going to do that, it should happen unconditionally, not just when we ended up with a zero significand.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87835/new/
https://reviews.llvm.org/D87835
More information about the llvm-commits
mailing list