[libc-commits] [libc] [libc][NFC] Unify `FPBits` implementations (PR #76033)

Clement Courbet via libc-commits libc-commits at lists.llvm.org
Wed Dec 20 10:08:12 PST 2023


================
@@ -107,6 +114,14 @@ template <FPType fp_type> struct FPBitsCommon : private FPProperties<fp_type> {
   LIBC_INLINE constexpr bool is_zero() const {
     return (bits & EXP_SIG_MASK) == 0;
   }
+
+  LIBC_INLINE constexpr bool is_inf() const {
+    if constexpr (UP::ENCODING == FPEncoding::X86_ExtendedPrecision) {
----------------
legrosbuffle wrote:

It feels weird to have something specific here. I think we should have the same code for all types, which can simply be `return (bits & EXP_SIG_MASK) == (EXP_MASK | EXPLICIT_BIT_MASK);`. Then `FloatProperties<>::EXPLICIT_BIT_MASK` could be zero except for fp80. Or we can add a `bool REPRESENTS_LEADING_DIGIT`

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


More information about the libc-commits mailing list