]> git.ipfire.org Git - thirdparty/glibc.git/commit
math: Simplify and optimize modf implementation
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 16 Jun 2025 13:17:34 +0000 (10:17 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 18 Jun 2025 18:56:40 +0000 (15:56 -0300)
commitf165e244e4c72493cf52cd6c98f989321f29c677
tree7624c44dfb1c93bfe5133848577498281cd734b2
parent61cc9922f3cdcd71ed8977016b8180d409826240
math: Simplify and optimize modf implementation

Refactor the generic implementation to use math_config.h definitions,
and add an alternative one if the ABI supports truncf instructions
(gated through math-use-builtins-trunc.h).

The generic implementation generates similar code on x86_64, while
the optimization one for aarch64 (where truncf is supported as a
builtin by through frintz), the improvements are:

reciprocal-throughput           master    patch    difference
workload-0_1                    3.0595   3.0698        -0.34%
workload-1_maxint               5.1747   3.0542        40.98%
workload-maxint_maxfloat        3.4391   3.0349        11.75%
workload-integral               3.2732   3.0293         7.45%

latency                         master    patch    difference
workload-0_1                    3.5267   4.7107       -33.57%
workload-1_maxint               6.9074   4.7282        31.55%
workload-maxint_maxfloat        3.7210   4.7506       -27.67%
workload-integral               3.8634   4.8137       -24.60%

Checked on aarch64-linux-gnu and x86_64-linux-gnu.
Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
sysdeps/ieee754/dbl-64/math_config.h
sysdeps/ieee754/dbl-64/s_modf.c