[libc-commits] [libc] [libc][math] Fix low-precision range reporting and rounding (PR #236472)

via libc-commits libc-commits at lists.llvm.org
Thu Nov 5 08:50:04 PST 2026


================
@@ -141,8 +143,13 @@ LIBC_INLINE constexpr float16 exp2m1f16(float16 x) {
     if (x_abs <= 0x3000U) {
 #ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
       if (auto r = EXP2M1F16_EXCEPTS_LO.lookup(x_u);
-          LIBC_UNLIKELY(r.has_value()))
+          LIBC_UNLIKELY(r.has_value())) {
+        if (FPBits(r.value()).is_subnormal()) {
+          fputil::set_errno_if_required(ERANGE);
+          fputil::raise_except_if_required(FE_UNDERFLOW);
----------------
lntue wrote:

Use `raise_underflow_except_if_required`.

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


More information about the libc-commits mailing list