[libc-commits] [libc] [libc][math] Correct tanhf16 subnormal rounding and range reporting (PR #236480)
via libc-commits
libc-commits at lists.llvm.org
Thu Oct 29 09:59:27 PDT 2026
================
@@ -49,6 +49,25 @@ LIBC_INLINE float16 tanhf16(float16 x) {
uint16_t x_u = x_bits.uintval();
uint16_t x_abs = x_u & 0x7fffU;
+ // The correction to x is nonzero but less than half a subnormal ulp.
+ // Select the adjacent half value directly, preserving signed zero.
+ if (LIBC_UNLIKELY(x_abs != 0 && x_abs <= 0x0400U)) {
----------------
lntue wrote:
Move this inside the branch `if (x_abs <= 0x2f48U) ` below. And probably some simplification could be done.
https://github.com/llvm/llvm-project/pull/236480
More information about the libc-commits
mailing list