[libc-commits] [libc] [libc][math] Update getpayload and fmul with NaN inputs. (PR #99812)
via libc-commits
libc-commits at lists.llvm.org
Sun Jul 21 14:19:17 PDT 2024
================
@@ -50,19 +50,19 @@ mul(InType x, InType y) {
raise_except_if_required(FE_INVALID);
if (x_bits.is_quiet_nan()) {
- InStorageType x_payload = static_cast<InStorageType>(getpayload(x));
- if ((x_payload & ~(OutFPBits::FRACTION_MASK >> 1)) == 0)
- return OutFPBits::quiet_nan(x_bits.sign(),
- static_cast<OutStorageType>(x_payload))
- .get_val();
+ InStorageType x_payload = x_bits.get_mantissa();
+ x_payload >>= (InFPBits::FRACTION_LEN - OutFPBits::FRACTION_LEN);
+ return OutFPBits::quiet_nan(x_bits.sign(),
+ static_cast<OutStorageType>(x_payload))
+ .get_val();
----------------
lntue wrote:
Most of the nan-propagations, especially binary operations, seem to be best-effort, and a bit underspecified in both IEEE 754 and C standards.
https://github.com/llvm/llvm-project/pull/99812
More information about the libc-commits
mailing list