[libc-commits] [libc] [libc] Make `BigInt` bitwise shift consistent with regular integral semantics. (PR #87762)

via libc-commits libc-commits at lists.llvm.org
Fri Apr 5 05:46:12 PDT 2024


================
@@ -122,15 +122,17 @@ template <size_t Bits> struct DyadicFloat {
 
     int exp_lo = exp_hi - static_cast<int>(PRECISION) - 1;
 
-    MantissaType m_hi(mantissa >> shift);
+    MantissaType m_hi =
+        shift >= MantissaType::BITS ? MantissaType(0) : mantissa >> shift;
----------------
lntue wrote:

Do we need the checks here and below?  The above computations guaranteed that `0 < shift < MantissaType::Bits = Bits`.

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


More information about the libc-commits mailing list