[PATCH v2 0/4] Minor optimization on CORE-MATH routines
Adhemerval Zanella
adhemerval.zanella@linaro.org
Tue Oct 14 12:10:30 GMT 2025
After our recent discussion on the performance impact of fma usage in
CORE-MATH routines, I profiled the relevant benchmarks on x86_64-v1,
i686, and armhf platforms. The fma appeared in the fast path for acoshf,
acospif, asinhf, asinpif, erfcf, and log2pf.
For asinpif and log2p1f, fma is only needed within a specific value
range to prevent unexpected exceptions. The __FP_FAST_FMA macro controls
an additional test to select the default path when appropriate.
I implemented a minor optimization in tgammaf by introducing binary
search on the accurate path.
Profiling showed that roundeven() is used in coshf, expm1f, sinhf, tanf,
tanpif, and gammaf. We may need to update the algorithm to improve its
performance. On armhf and possibly other ISAs, floorf and
double-to-long-long conversions (__aeabi_d2lz) were observed in exp10m1f
and exp2m1f.
[1] https://sourceware.org/pipermail/libc-alpha/2025-October/170779.html
Changes from v1:
- Add tests to stress the values that might be incorrectly rounded.
- Rewrite the binary seach on tgammaf.
Adhemerval Zanella (4):
math: Optimize fma call on asinpif
math: Optimize fma call on log2pf1
math: Use stdbit.h instead of builtin in math_config.h
math: Use binary search on lgammaf slow path
math/auto-libm-test-in | 6 +++
math/auto-libm-test-out-asinpi | 50 ++++++++++++++++++
math/auto-libm-test-out-lgamma | 75 ++++++++++++++++++++++++++
math/auto-libm-test-out-log2p1 | 25 +++++++++
sysdeps/ieee754/flt-32/e_lgammaf_r.c | 78 ++++++++++++++--------------
sysdeps/ieee754/flt-32/math_config.h | 7 +--
sysdeps/ieee754/flt-32/s_asinpif.c | 9 +++-
sysdeps/ieee754/flt-32/s_log2p1f.c | 7 ++-
8 files changed, 212 insertions(+), 45 deletions(-)
--
2.43.0
More information about the Libc-alpha
mailing list