[libc-commits] [PATCH] D129241: [libc][nfc] update get_explicit_mantissa

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jul 7 10:13:35 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6656029a4914: [libc][nfc] update get_explicit_mantissa (authored by michaelrj).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129241

Files:
  libc/src/__support/FPUtil/FPBits.h
  libc/src/__support/FPUtil/x86_64/LongDoubleBits.h


Index: libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
===================================================================
--- libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
+++ libc/src/__support/FPUtil/x86_64/LongDoubleBits.h
@@ -60,6 +60,10 @@
 
   UIntType get_mantissa() const { return bits & FloatProp::MANTISSA_MASK; }
 
+  UIntType get_explicit_mantissa() const {
+    return bits & (FloatProp::MANTISSA_MASK | FloatProp::EXPLICIT_BIT_MASK);
+  }
+
   void set_unbiased_exponent(UIntType expVal) {
     expVal =
         (expVal << (FloatProp::BIT_WIDTH - 1 - FloatProp::EXPONENT_WIDTH)) &
Index: libc/src/__support/FPUtil/FPBits.h
===================================================================
--- libc/src/__support/FPUtil/FPBits.h
+++ libc/src/__support/FPUtil/FPBits.h
@@ -59,11 +59,6 @@
 
   UIntType get_mantissa() const { return bits & FloatProp::MANTISSA_MASK; }
 
-  // The function return mantissa with implicit bit set for normal values.
-  constexpr UIntType get_explicit_mantissa() {
-    return (FloatProp::MANTISSA_MASK + 1) | (FloatProp::MANTISSA_MASK & bits);
-  }
-
   void set_unbiased_exponent(UIntType expVal) {
     expVal = (expVal << (FloatProp::MANTISSA_WIDTH)) & FloatProp::EXPONENT_MASK;
     bits &= ~(FloatProp::EXPONENT_MASK);
@@ -75,6 +70,15 @@
                     (FloatProp::MANTISSA_WIDTH));
   }
 
+  // The function return mantissa with the implicit bit set iff the current
+  // value is a valid normal number.
+  constexpr UIntType get_explicit_mantissa() {
+    return ((get_unbiased_exponent() > 0 && !is_inf_or_nan())
+                ? (FloatProp::MANTISSA_MASK + 1)
+                : 0) |
+           (FloatProp::MANTISSA_MASK & bits);
+  }
+
   void set_sign(bool signVal) {
     bits |= FloatProp::SIGN_MASK;
     if (!signVal)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129241.442970.patch
Type: text/x-patch
Size: 1793 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220707/9d6cb004/attachment-0001.bin>


More information about the libc-commits mailing list