mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-31 14:01:18 +08:00
math: Fix acosf when building with gcc <= 11
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
This commit is contained in:
parent
e41aabcc93
commit
9cc9f8e11e
@ -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":
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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":
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user