[COMMITTED] math: Sync acosf with CORE-MATH

Adhemerval Zanella adhemerval.zanella@linaro.org
Mon Sep 21 12:38:50 GMT 2026


Import CORE-MATH revision 50864ddf.

The results are unchanged in all four rounding modes.

Checked on aarch64-linux-gnu.
---
 SHARED-FILES                     |  2 +-
 sysdeps/ieee754/flt-32/e_acosf.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/SHARED-FILES b/SHARED-FILES
index fb15c2c92d..9eedb597e7 100644
--- a/SHARED-FILES
+++ b/SHARED-FILES
@@ -283,7 +283,7 @@ core-math:
   sysdeps/ieee754/dbl-64/s_erfc.c
   # src/binary64/tanh/tanh.c, revision dbd377a9
   sysdeps/ieee754/dbl-64/s_tanh.c
-  # src/binary32/acos/acosf.c, revision 56dd347
+  # src/binary32/acos/acosf.c, revision 50864ddf
   sysdeps/ieee754/flt-32/e_acosf.c
   # src/binary32/acosh/acoshf.c, revision d0b9ddd
   sysdeps/ieee754/flt-32/e_acoshf.c
diff --git a/sysdeps/ieee754/flt-32/e_acosf.c b/sysdeps/ieee754/flt-32/e_acosf.c
index 79deecaa54..3dd880b950 100644
--- a/sysdeps/ieee754/flt-32/e_acosf.c
+++ b/sysdeps/ieee754/flt-32/e_acosf.c
@@ -3,7 +3,7 @@
 Copyright (c) 2023-2024 Alexei Sibidanov.
 
 The original version of this file was copied from the CORE-MATH
-project (file src/binary32/acos/acosf.c, revision 56dd347).
+project (file src/binary32/acos/acosf.c, revision 50864ddf).
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -91,10 +91,12 @@ __acosf (float x)
 	};
       /* Avoid spurious underflow exception.  */
       if (__glibc_unlikely (ax <= 0x40000000u)) /* |x| < 2^-63 */
-	/* GCC <= 11 wrongly assumes the rounding is to nearest and
-	   performs a constant folding here:
-	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57245 */
-	return math_opt_barrier (pi2);
+	{
+	  /* (float) pi2 would round pi/2 twice (to double, then to float);
+	     the sum below rounds once, in the current rounding mode.  */
+	  static const float pi2h = 0x1.921fb6p+0f, pi2l = -0x1.777a5cp-25f;
+	  return pi2h + pi2l;
+	}
       double z = xs;
       double z2 = z * z;
       double z4 = z2 * z2;
-- 
2.47.3



More information about the Libc-alpha mailing list