Commit a5efd38
fix(erf): erfc_profile_band_tail used (-x*x).exp() => interposed-exp round-trip (bd-2g7oyh.371)
Same anti-pattern class as the log2f recursion bug (bd-2g7oyh.370): the std
f64::exp lowers to a call to the exp symbol, which in the shipped libc.so is
our OWN interposed exp. So the hot erf/erfc path (erfc_profile_band_tail, hit
by erf for x in [1,2.5) and by all of erfc) paid a full membrane round-trip
(runtime_policy decide/observe + re-entry into core::exp) on every call, instead
of a direct inlined polynomial.
Worse, it was a TEST/SHIPPED divergence: in the glibc-linked test binary
(-x*x).exp() binds to GLIBC's exp, so conformance_diff_math validated an erf
built on glibc's exp -- NOT the shipped erf, which used core::exp (with its own
4-ULP exp2 fast path). The real shipped erf accuracy was never tested.
Fix: libm::exp(-x * x) (pure Rust, no symbol round-trip), consistent with the
tgamma path's libm::exp(-t) a few lines below and the rest of the math tree.
Now the test and the shipped library compute the same thing. Verified within the
4-ULP glibc contract: conformance_diff_math (17), conformance_diff_math_special
(diff_erf/erfc_*_within_4_ulps), conformance_diff_math_exact (9), and core
math::special erf/erfc sanity all green.
LESSON (see also bd-2g7oyh.370): audit production interposed-symbol code for std
float methods (.exp()/.ln()/.log2()/.powf()/...) -- they bind to the interposed
libm symbol (membrane round-trip at best, self-recursion at worst). Use libm::*
directly. This was the only remaining production instance (.sqrt() is a hardware
insn, safe).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 148c9cb commit a5efd38
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
| |||
0 commit comments