[PATCH v2 2/4] math: Optimize fma call on log2pf1
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Tue Oct 14 13:18:15 GMT 2025
Hi Adhemerval,
> +++ b/sysdeps/ieee754/flt-32/s_log2p1f.c
> @@ -231,7 +231,12 @@ __log2p1f (float x)
> int j = (m + ((int64_t) 1 << (52 - 8))) >> (52 - 7), k = j > 53;
> e += k;
> double xd = asdouble (m | (uint64_t) 0x3ff << 52);
>- z = fma (xd, ix[j], -1.0);
> +#ifndef __FP_FAST_FMA
> + if (__glibc_unlikely (x == -0x1.da285cp-5f))
> + z = fma (xd, ix[j], -1.0);
> + else
> +#endif
> + z = xd * ix[j] - 1.0;
This relies on fp contraction on targets with FMA. I think it's best to do
the same as in previous patch, reverse the if condition and use fma in
the else part.
Cheers,
Wilco
More information about the Libc-alpha
mailing list