[libclc] [libclc] Produce subnormal results for exp/exp2 on FP32 (PR #212696)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 7 02:58:18 PDT 2026
Lurie97 wrote:
@arsenm Reworked to scale with `__clc_ldexp` directly, matching the ocml
`expF_base.h` flow, and dropped the fixup path.
- **Normal results unchanged:** `ldexp(y, p)` is bit-identical to the old
`as_int(y) + (p << 23)` for normal results; only the subnormal range changes.
- **`llim`:** `exp` uses `ln(2^-149)`, `exp2` uses `-149` — the smallest
subnormal, rounded so the boundary input isn't flushed (no off-by-one).
- **Clamp `[-151, 129]`:** representable `p ∈ [-149, 128]` for both, so the
clamp only catches inputs already saturated to inf/zero by the ulim/llim
selects. Without it, extreme inputs made `ldexp` return NaN.
Verified on i.MX95 Mali-G310 (FTZ device): CTS `math_brute_force` exp/exp2 pass
6/6. Re-requested your review — happy to make the clamp bounds named constants.
https://github.com/llvm/llvm-project/pull/212696
More information about the cfe-commits
mailing list