[PATCH 2/8] math: Optimize fma call on acospif
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Oct 13 11:41:40 GMT 2025
On 13/10/25 06:15, Paul Zimmermann wrote:
> Hi,
>
> LGTM with one minor change below.
>
> Tested by exhaustive test with all rounding modes, with the CORE-MATH
> test suite and -march=x86-64-v2.
>
> Reviewed-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
>
> Paul
>
>> From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
>> Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>,
>> Paul Zimmermann <Paul.Zimmermann@inria.fr>,
>> DJ Delorie <dj@redhat.com>
>> Date: Fri, 10 Oct 2025 14:49:20 -0300
>>
>> The fma is required only for inputs less than 0x1.0fd288p-127. Also
>> only add the extra check for !__FP_FAST_FMA targets.
>>
>> Checked on x86_64-linux-gnu and aarch64-linux-gnu.
>> ---
>> sysdeps/ieee754/flt-32/s_acospif.c | 7 ++++++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/sysdeps/ieee754/flt-32/s_acospif.c b/sysdeps/ieee754/flt-32/s_acospif.c
>> index caf65d42f3d..63230bd3b37 100644
>> --- a/sysdeps/ieee754/flt-32/s_acospif.c
>> +++ b/sysdeps/ieee754/flt-32/s_acospif.c
>> @@ -67,7 +67,12 @@ __acospif (float x)
>> /* For |x| <= 0x1.0fd288p-127, c0 += c4*(z4*z4) would raise a spurious
>> underflow exception, we use an FMA instead, where c4 * z4 does not
>> underflow. */
>> - c0 = fma (c4 * z4, z4, c0);
>> +#ifndef __FP_FAST_FMA
>> + if (__glibc_likely (ax > 0x1.0fd288p-127))
>
> should be 0x1.0fd288p-127f (ax is a float)
Yes, I will change it.
>
>> + c0 = (c4 * z4) * z4 + c0;
>> + else
>> +#endif
>> + c0 = fma (c4 * z4, z4, c0);
>> return 0.5 - z * c0;
>> }
>> else
>> --
>> 2.43.0
>>
>>
More information about the Libc-alpha
mailing list