[libc-commits] [libc] [libc][NFC] Simplify `FPBits` (PR #76835)

Clement Courbet via libc-commits libc-commits at lists.llvm.org
Wed Jan 3 09:40:10 PST 2024


================
@@ -37,20 +37,21 @@ struct FPBits<long double> : public internal::FPRep<FPType::X86_Binary80> {
   using UP::QUIET_NAN_MASK;
 
 public:
-  static constexpr int MAX_BIASED_EXPONENT = 0x7FFF;
+  static constexpr int MAX_BIASED_EXPONENT = (1 << EXP_LEN) - 1;
+  // The x86 80 bit float represents the leading digit of the mantissa
+  // explicitly. This is the mask for that bit.
+  static constexpr StorageType EXPLICIT_BIT_MASK = StorageType(1)
+                                                   << FRACTION_LEN;
+  static_assert((EXPLICIT_BIT_MASK & FRACTION_MASK) == 0, "mask disjoint");
----------------
legrosbuffle wrote:

```
// The X80 significand is made of an explicit bit and the fractional part.
static_assert((EXPLICIT_BIT_MASK & FRACTION_MASK) == 0, "the explicit bit and the fractional part should not overlap");
static_assert((EXPLICIT_BIT_MASK | FRACTION_MASK) == SIG_MASK, "the explicit bit and the fractional part should cover the whole significand");

```



https://github.com/llvm/llvm-project/pull/76835


More information about the libc-commits mailing list