aboutsummaryrefslogtreecommitdiff
path: root/libc/utils
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2020-06-22 13:47:56 -0700
committerSiva Chandra Reddy <sivachandra@google.com>2020-06-22 23:02:05 -0700
commit987fac79c9a951806cbda6b178b05fcb5145fde8 (patch)
tree6fa3415684826af81e8aad9be55e7cb66e956099 /libc/utils
parentf95850ce9c7593d3d8d2f83c55197970f373b9ad (diff)
downloadllvm-987fac79c9a951806cbda6b178b05fcb5145fde8.zip
llvm-987fac79c9a951806cbda6b178b05fcb5145fde8.tar.gz
llvm-987fac79c9a951806cbda6b178b05fcb5145fde8.tar.bz2
[libc] Match x86 long double NaN classification with that of the compiler.
Reviewers: asteinhauser Differential Revision: https://reviews.llvm.org/D82330
Diffstat (limited to 'libc/utils')
-rw-r--r--libc/utils/FPUtil/LongDoubleBitsX86.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/libc/utils/FPUtil/LongDoubleBitsX86.h b/libc/utils/FPUtil/LongDoubleBitsX86.h
index 1e92dba..3d7f455 100644
--- a/libc/utils/FPUtil/LongDoubleBitsX86.h
+++ b/libc/utils/FPUtil/LongDoubleBitsX86.h
@@ -62,9 +62,18 @@ template <> struct __attribute__((packed)) FPBits<long double> {
return exponent == maxExponent && mantissa == 0 && implicitBit == 1;
}
- bool isNaN() const { return exponent == maxExponent && mantissa != 0; }
+ bool isNaN() const {
+ if (exponent == maxExponent) {
+ return (implicitBit == 0) || mantissa != 0;
+ } else if (exponent != 0) {
+ return implicitBit == 0;
+ }
+ return false;
+ }
- bool isInfOrNaN() const { return exponent == maxExponent; }
+ bool isInfOrNaN() const {
+ return (exponent == maxExponent) || (exponent != 0 && implicitBit == 0);
+ }
// Methods below this are used by tests.