]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix acosf when building with gcc <= 11
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 2 Jan 2025 13:54:11 +0000 (10:54 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 9 Jan 2025 15:53:58 +0000 (12:53 -0300)
GCC <= 11 wrongly assumes the rounding is to nearest and performs a
constant folding where it should evaluate since the result is not
exact [1].

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57245

sysdeps/aarch64/libm-test-ulps
sysdeps/i386/fpu/libm-test-ulps
sysdeps/i386/i686/fpu/multiarch/libm-test-ulps
sysdeps/ieee754/flt-32/e_acosf.c
sysdeps/powerpc/fpu/libm-test-ulps
sysdeps/s390/fpu/libm-test-ulps
sysdeps/x86_64/fpu/libm-test-ulps

index a813938d28e34946b6cd81433cd733c67f2df111..59ec92917642877f564833fd91bb698618fa914d 100644 (file)
@@ -11,7 +11,6 @@ float: 1
 
 Function: "acos_downward":
 double: 1
-float: 1
 ldouble: 1
 
 Function: "acos_sve":
@@ -20,7 +19,6 @@ float: 1
 
 Function: "acos_towardzero":
 double: 1
-float: 1
 ldouble: 1
 
 Function: "acos_upward":
index 8f3eeb89995314bfa8a20fc16751958619a0447c..737d4cc86a88d52918df97d9b237614738009a3f 100644 (file)
@@ -7,12 +7,10 @@ float128: 1
 ldouble: 2
 
 Function: "acos_downward":
-float: 1
 float128: 1
 ldouble: 2
 
 Function: "acos_towardzero":
-float: 1
 float128: 1
 ldouble: 2
 
index d411751ce83e8074e0162d52ad1fbf20f4b776bb..750d51906b5eda53fceb8e3d3eae387e2cfa7235 100644 (file)
@@ -7,12 +7,10 @@ float128: 1
 ldouble: 2
 
 Function: "acos_downward":
-float: 1
 float128: 1
 ldouble: 2
 
 Function: "acos_towardzero":
-float: 1
 float128: 1
 ldouble: 2
 
index cba01221dc1d812b8eee198ef166e031946ef152..a5a4de4fc2d9e1088b5ee6fb0f53b20bf6c113e1 100644 (file)
@@ -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 61d7bef).
+project (file src/binary32/acos/acosf.c, revision 56dd347).
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -28,6 +28,7 @@ SOFTWARE.
 #include <math.h>
 #include <math_private.h>
 #include <libm-alias-finite.h>
+#include <math-barriers.h>
 #include "math_config.h"
 
 static __attribute__ ((noinline)) float
@@ -66,7 +67,7 @@ poly12 (double z, const double *c)
 float
 __ieee754_acosf (float x)
 {
-  const double pi2 = 0x1.921fb54442d18p+0;
+  double pi2 = 0x1.921fb54442d18p+0;
   static const double o[] = { 0, 0x1.921fb54442d18p+1 };
   double xs = x;
   double r;
@@ -87,7 +88,10 @@ __ieee754_acosf (float x)
        };
       /* Avoid spurious underflow exception.  */
       if (__glibc_unlikely (ax <= 0x40000000u)) /* |x| < 2^-63 */
-       return (float) pi2;
+       /* 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);
       double z = xs;
       double z2 = z * z;
       double z4 = z2 * z2;
index 22cbb8329d3d66af77f6e14a5f5ec456ed421968..cf3dec38a9303ba52417e20ea2a7d42d8e50610c 100644 (file)
@@ -8,13 +8,11 @@ ldouble: 1
 
 Function: "acos_downward":
 double: 1
-float: 1
 float128: 1
 ldouble: 3
 
 Function: "acos_towardzero":
 double: 1
-float: 1
 float128: 1
 ldouble: 3
 
index 92e2cc7f77d7a6e75da08df228448fe3eb5b6a78..76a1f3c7e581a6e95b3503230a4803a3421784bc 100644 (file)
@@ -7,12 +7,10 @@ ldouble: 1
 
 Function: "acos_downward":
 double: 1
-float: 1
 ldouble: 1
 
 Function: "acos_towardzero":
 double: 1
-float: 1
 ldouble: 1
 
 Function: "acos_upward":
index 8472cc6b84b7bc0980a9b39c692f9d544c5fce0d..e454a63eea1c6a16dfd2d0e6d4659312262e5b7f 100644 (file)
@@ -8,13 +8,11 @@ ldouble: 2
 
 Function: "acos_downward":
 double: 1
-float: 1
 float128: 1
 ldouble: 2
 
 Function: "acos_towardzero":
 double: 1
-float: 1
 float128: 1
 ldouble: 2