This patch currently only affects aarch64.
The roundtoint and converttoint internal functions are only called with small
values, so 32 bit result is enough for converttoint and it is a signed int conversion so the return type is changed to int32_t.
The original idea was to help the compiler keeping the result in uint64_t, then it's clear that no sign extension is needed and there is no accidental undefined or implementation defined signed int arithmetics.
But it turns out gcc does a good job with inlining so changing the type has no overhead and the semantics of the conversion is less surprising this way. Since we want to allow the asuint64 (x + 0x1.8p52) style conversion, the top bits were never usable and the existing code ensures that only the bottom 32 bits of the conversion result are used.
On aarch64 the neon intrinsics (which round ties to even) are changed to round and lround (which round ties away from zero) this does not affect the results in a significant way, but more portable (relies on round and lround being inlined which works with -fno-math-errno).
The TOINT_SHIFT and TOINT_RINT macros were removed, only keep separate code paths for TOINT_INTRINSICS and !TOINT_INTRINSICS.
- sysdeps/aarch64/fpu/math_private.h (roundtoint): Use round. (converttoint): Use lround.
- sysdeps/ieee754/flt-32/math_config.h (roundtoint): Declare and document the semantics when TOINT_INTRINSICS is set. (converttoint): Likewise. (TOINT_RINT): Remove. (TOINT_SHIFT): Remove.
- sysdeps/ieee754/flt-32/e_expf.c (__expf): Remove the TOINT_RINT code path.
43cfdf8f48 Clean up converttoint handling and document the semantics
ChangeLog | 13 +++++++++++++
sysdeps/aarch64/fpu/math_private.h | 17 +++++++----------
sysdeps/ieee754/flt-32/e_expf.c | 5 +----
sysdeps/ieee754/flt-32/math_config.h | 20 +++++++++++++++-----
4 files changed, 36 insertions(+), 19 deletions(-)