[PATCH 4/8] math: math: Optimize fma call on asinpif

Adhemerval Zanella adhemerval.zanella@linaro.org
Fri Oct 10 17:49:22 GMT 2025


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);
+#endif
+      return fma (-c0, copysign (f, x), copysign (0.5, x));
     }
 }
 libm_alias_float (__asinpi, asinpi)
-- 
2.43.0



More information about the Libc-alpha mailing list