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

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Wed Dec 20 07:18:02 PST 2023


================
@@ -84,13 +84,12 @@ struct FPBits<long double>
   }
 
   LIBC_INLINE constexpr void set_sign(bool signVal) {
-    bits &= ~SIGN_MASK;
-    StorageType sign1 = StorageType(signVal) << (TOTAL_LEN - 1);
-    bits |= sign1;
+    if (get_sign() != signVal)
----------------
gchatelet wrote:

I don't think this works, the code "**inverts** the bit if `signVal` is set regardless of the state of `bits`" what we want is to "**set** the bit if `signVal` is set and **clear** it otherwise".

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


More information about the libc-commits mailing list