[PATCH 4/8] math: math: Optimize fma call on asinpif
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Mon Oct 13 16:30:26 GMT 2025
On 13/10/25 06:23, Paul Zimmermann wrote:
> Hi Adhemerval,
>
>> 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:22 -0300
>>
>> The fma is required only for x == 0x1.6371e8p-4f in FE_TOWARDZERO
>> to provide correctly rounded results.
>>
>> Checked on x86_64-linux-gnu and aarch64-linux-gnu.
>> ---
>> sysdeps/ieee754/flt-32/s_asinpif.c | 9 +++++++--
>> 1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/sysdeps/ieee754/flt-32/s_asinpif.c b/sysdeps/ieee754/flt-32/s_asinpif.c
>> index f9e93533d4a..d5e8a90aaa8 100644
>> --- a/sysdeps/ieee754/flt-32/s_asinpif.c
>> +++ b/sysdeps/ieee754/flt-32/s_asinpif.c
>> @@ -79,8 +79,13 @@ __asinpif (float x)
>> c0 += c2 * z2;
>> c4 += c6 * z2;
>> c0 += c4 * z4;
>> - double r = fma (-c0, copysign (f, x), copysign (0.5, x));
>> - return r;
>> +#ifndef __FP_FAST_FMA
>> + /* The fma is required only for x == 0x1.6371e8p-4f in FE_TOWARDZERO
>> + to provide correctly rounded results. */
>> + if (__glibc_likely (x != 0x1.6371e8p-4f))
>> + return copysign (0.5, x) - c0 * copysign (f, x);
>
> with CORE-MATH and -march=x86-64-v2, I also get an error for -0x1.6371e8p-4f.
> Please can you check that value and maybe add it to math/auto-libm-test-in?
It should be 'ax' on the test, I will add the related auto-libm-test-in.
>
>> +#endif
>> + return fma (-c0, copysign (f, x), copysign (0.5, x));
>> }
>> }
>> libm_alias_float (__asinpi, asinpi)
>> --
>> 2.43.0
>
> Paul
More information about the Libc-alpha
mailing list