[PATCH 0/8] Minor optimization on CORE-MATH routines

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Oct 10 17:49:18 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 acosh, asinhf, erfcf, and log2p1f, fma is not necessary to achieve
correctly rounded results. I verified this across all possible input
values.

For acospif and asinpif, 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

Adhemerval Zanella (8):
  math: Remove acoshf fma usage
  math: Optimize fma call on acospif
  math: Remove asinhf fma usage
  math: math: Optimize fma call on asinpif
  math: Remove erfcf fma usage
  math: Remove log2pf1 fma usage
  math: Use stdbit.h instead of builtin in math_config.h
  math: Use binary search on tgammaf slow path

 sysdeps/ieee754/flt-32/e_acoshf.c    |  4 +-
 sysdeps/ieee754/flt-32/e_lgammaf_r.c | 56 ++++++++++++++++------------
 sysdeps/ieee754/flt-32/math_config.h |  7 ++--
 sysdeps/ieee754/flt-32/s_acospif.c   |  7 +++-
 sysdeps/ieee754/flt-32/s_asinhf.c    |  4 +-
 sysdeps/ieee754/flt-32/s_asinpif.c   |  9 ++++-
 sysdeps/ieee754/flt-32/s_erfcf.c     |  2 +-
 sysdeps/ieee754/flt-32/s_log2p1f.c   |  2 +-
 8 files changed, 55 insertions(+), 36 deletions(-)

-- 
2.43.0



More information about the Libc-alpha mailing list