[glibc] powerpc: Update acosf ulps
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Jan 2 14:07:46 GMT 2025
On 02/01/25 11:05, Paul Zimmermann wrote:
> Hi Adhemerval,
>
>> This seems to show no regression on gcc 11 and gcc 13 on x86_64, i686, aarch64,
>> and powerpc64le:
>>
>> diff --git a/sysdeps/ieee754/flt-32/e_acosf.c b/sysdeps/ieee754/flt-32/e_acosf.c
>> index cba01221dc..35e241f6c4 100644
>> --- a/sysdeps/ieee754/flt-32/e_acosf.c
>> +++ b/sysdeps/ieee754/flt-32/e_acosf.c
>> @@ -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;
>
> this looks good to me, with two questions:
>
> 1) why did you remove "const" in pi2 ? This does not work with const ?
Because gcc complains due how math_opt_barrier is implemented:
../sysdeps/ieee754/flt-32/e_acosf.c: In function ‘__ieee754_acosf’:
../sysdeps/aarch64/fpu/math-barriers.h:23:30: error: read-only variable ‘__x’ used as ‘asm’ output
23 | ({ __typeof (x) __x = (x); __asm ("" : "+w" (__x)); __x; })
| ^~~~~
../sysdeps/ieee754/flt-32/e_acosf.c:94:16: note: in expansion of macro ‘math_opt_barrier’
94 | return math_opt_barrier (pi2);
| ^~~~~~~~~~~~~~~~
>
> 2) does math_opt_barrier() return a float? Or is the return value cast
> to float by the return?
The later, since math_opt_barrier aims to be type agnostic by using
__typeof.
>
> Paul
More information about the Libc-alpha
mailing list