[PATCH 11/15] math: Fix acos template for arguments greater than 1

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Wed Mar 27 17:58:07 GMT 2024



On 27/03/24 14:14, Joseph Myers wrote:
> On Wed, 27 Mar 2024, Adhemerval Zanella wrote:
> 
>> The template is used by some ABsI for static build, and it fails set
>> the expected floating exceptions if the argument is outside of the
>> range (on x86_64 this triggers an overflow calculation in
>> __ieee754_acos).
> 
> Patches 11 through 15 all seem incorrect; it's the responsibility of the 
> __ieee754_* functions to raise the correct exceptions, not of the 
> wrappers.  Please make sure you don't have a compiler with a bug like 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95115 miscompiling those 
> __ieee754_* functions.
> 

The failures are both:

math/test-float64x-acos-static
math/test-ldouble-acos-static

$ cat math/test-ldouble-acos-static.out
testing long double (without inline functions)
Failure: acos (max_value): Exception "Overflow" set
Failure: acos (-max_value): Exception "Overflow" set
Failure: acos_downward (max_value): Exception "Overflow" set
Failure: acos_downward (-max_value): Exception "Overflow" set
Failure: acos_towardzero (max_value): Exception "Overflow" set
Failure: acos_towardzero (-max_value): Exception "Overflow" set
Failure: acos_upward (max_value): Exception "Overflow" set
Failure: acos_upward (-max_value): Exception "Overflow" set

Test suite completed:
  452 test cases plus 448 tests for exception flags and
    448 tests for errno executed.
  8 errors occurred.

And I think it is unrelated to gcc PR95115 because x86_64/i686 will use
and specific sysdeps/i386/fpu/e_acosl.c that explicit does not handle this
input case for overflow exceptions.  For shared build this case is
handle by w_acosl_compat.c:

  if (__builtin_expect (isgreater (fabsl (x), 1.0L), 0)
      && _LIB_VERSION != _IEEE_)
    {
      /* acos(|x|>1) */
      feraiseexcept (FE_INVALID);
      return __kernel_standard_l (x, x, 201);
    }

And that's why I though following the same logic on template would be
better.  But I think maybe we should fix on x86_64 implementation instead.


More information about the Libc-alpha mailing list