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

Wilco Dijkstra Wilco.Dijkstra@arm.com
Tue Oct 14 13:57:46 GMT 2025


Hi Adhemerval,

> 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.

That code is pretty horrible, but it's obvious both the floor() and double to long
conversions are redundant. For truncation you can use (int)x since the range is
small enough that 32-bits is fine, but it's not clear why it isn't using the standard
approach of TOINT_INTRINSICS where the rounding helps to improve accuracy
of the polynomial. Perhaps we could generalize this approach further given most
math functions need this.

Cheers,
Wilco


More information about the Libc-alpha mailing list