Commit Graph

1540 Commits

Author SHA1 Message Date
Paul Zimmermann e5ca265a9c new inputs with large errors for [a]cospi, [a]sinpi, [a]tanpi, atan2pi
These inputs were generated with the programs from
https://gitlab.inria.fr/zimmerma/math_accuracy,
with rounding to nearest:

* for univariate binary32 functions by exhaustive search
* for other functions with the "threshold" parameter up to 10^6
2025-01-02 18:26:36 +01:00
Paul Eggert 2642002380 Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
Adhemerval Zanella 03962d17c9 math: Fix clang warnings for math/test-tgmath-ret.c
clang warns that since the global variables are only used to function
calls (without being actually used), they are not needed and will
not be emitted.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2024-12-22 17:40:33 +08:00
H.J. Lu 56cdc529fb Add test-config-cflags-float-store for -ffloat-store
Clang doesn't support -ffloat-store:

clang: error: optimization flag '-ffloat-store' is not supported [-Werror,-Wignored-optimization-argument]

Define test-config-cflags-float-store for -ffloat-store and use it in
math/Makefile for testing.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2024-12-22 13:02:30 +08:00
H.J. Lu bdc7f4b4e2 Don't redefine INFINITY nor NAN
Since math/math.h isn't a system header, clang issues errors:

In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:91:11: error: 'INFINITY' macro redefined [-Werror,-Wmacro-redefined]
   91 | #  define INFINITY (__builtin_inff ())
      |           ^
/usr/bin/../lib/clang/19/include/float.h:173:11: note: previous definition is here
  173 | #  define INFINITY (__builtin_inff())
      |           ^
In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:98:11: error: 'NAN' macro redefined [-Werror,-Wmacro-redefined]
   98 | #  define NAN (__builtin_nanf (""))
      |           ^
/usr/bin/../lib/clang/19/include/float.h:174:11: note: previous definition is here
  174 | #  define NAN (__builtin_nanf(""))

Don't define INFINITY nor NAN if they are defined.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2024-12-22 12:44:42 +08:00
H.J. Lu 6d9d7865d0 Check Clang 12 for __builtin_complex
Since __builtin_complex was added to Clang 12, support __builtin_complex
for Clang 12.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2024-12-22 12:43:14 +08:00
H.J. Lu 969d7cf899 math: Exclude tgmath3-macro-tests for Clang
tgmath3-macro-tests won't compile with <float.h> and <tgmath.h> from
Clang due to missing C23 support:

https://github.com/llvm/llvm-project/issues/97335

Disable them for now when Clang is used for testing so that "make check"
can finish.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-12-22 06:07:17 +08:00
H.J. Lu 034cd67528 Don't use glibc <tgmath.h> when testing with Clang
Clang has its own <tgmath.h> and doesn't use <tgmath.h> from glibc.  Pass
"-I." to compiler only if $($(<F)-no-include-dot) are undefined.  Define
it to yes for tgmath tests when testing with Clang.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2024-12-21 05:24:07 +08:00
Adhemerval Zanella c3ee510267 math: xfail some tanpi tests for ibm128-libgcc
On powerpc math/test-ibm128-tanpi shows multiple failures:

testing long double (without inline functions)
Failure: tanpi_downward (0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_downward (0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_downward (0xfffffffffffffffdp-1)
Result:
 is:          4.68843873182857939141363635204365e+28   0x1.2efbb6629d1d59b032520400df8p+95
 should be:   inf   inf
Failure: tanpi_downward (0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_downward (0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_downward (0x3fffffffffffffffffffffffffdp-1)
Result:
 is:          1.41444453325831960404472183124793e+16   0x1.9202627cbf98e052d5fdbeee1f8p+53
 should be:   inf   inf
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
Failure: Test: tanpi_downward (0x3.fffffffffffffffcp+108)
Result:
 is:          2.91356019227449116879287504834896e-15   0x1.a3e365fee24d4632f95a2235698p-49
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  2.91356019227449116879287504834896e-15   0x1.a3e365fee24d4632f95a2235698p-49
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: Test: tanpi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          7.94911926685664643005642781870827e-16   0x1.ca3c4b83eb5688e1474146dc338p-51
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  7.94911926685664643005642781870827e-16   0x1.ca3c4b83eb5688e1474146dc338p-51
 ulp       :  160891965142034222272327839154722485473479235229008379884749401713481320342777314570400076204240982703218835644458374555276642
 max.ulp   :  8.0000
Failure: tanpi_towardzero (0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (0xfffffffffffffffdp-1)
Result:
 is:          2.14718475310122677917055904836884e+28   0x1.1584624c14882fff76592b4ec10p+94
 should be:   inf   inf
Failure: tanpi_towardzero (-0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (-0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (-0xfffffffffffffffdp-1)
Result:
 is:         -2.14718475310122677917055904836884e+28  -0x1.1584624c14882fff76592b4ec10p+94
 should be:  -inf  -inf
Failure: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1)
Result:
 is:          6.60739946234609289593176521179840e+15   0x1.7796511d79d6ce55bc8bf083fe0p+52
 should be:   inf   inf
Failure: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1)
Result:
 is:         -6.60739946234609289593176521179840e+15  -0x1.7796511d79d6ce55bc8bf083fe0p+52
 should be:  -inf  -inf
Failure: Test: tanpi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
 is:         -1.17953443892757434921819283936141e-14  -0x1.a8f8d97fb893518cbe5688935c0p-47
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.17953443892757434921819283936141e-14   0x1.a8f8d97fb893518cbe5688935c0p-47
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: Test: tanpi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:         -1.85584803206881692897837494734542e-14  -0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.85584803206881692897837494734542e-14   0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: Test: tanpi_towardzero (0x3.fffffffffffffffcp+108)
Result:
 is:          1.17953443892757434921819283936141e-14   0x1.a8f8d97fb893518cbe5688935c0p-47
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  1.17953443892757434921819283936141e-14   0x1.a8f8d97fb893518cbe5688935c0p-47
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: Test: tanpi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          1.85584803206881692897837494734542e-14   0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  1.85584803206881692897837494734542e-14   0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  8.0000
Failure: tanpi_upward (-0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_upward (-0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_upward (-0xfffffffffffffffdp-1)
Result:
 is:         -2.14718475310122677917055904836884e+28  -0x1.1584624c14882fff76592b4ec10p+94
 should be:  -inf  -inf
Failure: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1)
Result:
 is:         -6.60739946234609289593176521179829e+15  -0x1.7796511d79d6ce55bc8bf083fdbp+52
 should be:  -inf  -inf
Failure: Test: tanpi_upward (-0x3.fffffffffffffffcp+108)
Result:
 is:         -1.17953443892757434921819283936138e-14  -0x1.a8f8d97fb893518cbe5688935b0p-47
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.17953443892757434921819283936139e-14   0x1.a8f8d97fb893518cbe5688935b0p-47
 ulp       :  inf
 max.ulp   :  8.0000
Failure: Test: tanpi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:         -1.85584803206881692897837494734542e-14  -0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.85584803206881692897837494734543e-14   0x1.4e51e25c1f5ab4470a3a0a42c24p-46
 ulp       :  inf
 max.ulp   :  8.0000
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
2024-12-20 15:09:40 -03:00
Adhemerval Zanella 45126f866c math: Fix the expected carg (inf) results
The pi defined constants are not the expected value for carg
on non-default rounding modes (similar to atan).  Instead use
autogenerated value.
2024-12-18 17:24:43 -03:00
Adhemerval Zanella abe1d65aa6 math: Fix the expected atan2f (inf) results
The pi defined constants are not the expected value for atan2
on non-default rounding modes.  Instead use the autogenerated value.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:43 -03:00
Adhemerval Zanella 517c213377 math: Fix the expected atanf (inf) results
The M_PI_2 (lit_pi_2_d) constant is not the expected value for atanf
on non-default rounding modes.  Instead use the autogenerated value.
2024-12-18 17:24:43 -03:00
Adhemerval Zanella aa3e67ced6 math: Add inf support on gen-auto-libm-tests.c
For some correctly rounded inputs where infinity might generate
a number (like atanf), comparing to a pre-defined constant does not
yield the expected result in all rounding modes.

The most straightforward way to handle it would be to get the expected
result from mpfr, where it handles all the rounding modes.
2024-12-18 17:24:42 -03:00
Adhemerval Zanella a993eea641 math: Fix spurious-divbyzero flag name
Reviewed-by: DJ Delorie <dj@redhat.com>
2024-12-18 17:24:42 -03:00
Joseph Myers 3374de9038 Implement C23 atan2pi
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the atan2pi functions (atan2(y,x)/pi).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-12 20:57:44 +00:00
H.J. Lu 6bc301672b math: Remove __XXX math functions from installed math.h [BZ #32418]
Since libm doesn't export __XXX math functions, don't declare them in
the installed math.h by adding <bits/mathcalls-macros.h> to declare
__XXX math functions internally for glibc build.  This fixes BZ #32418.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
2024-12-12 16:17:54 +08:00
Joseph Myers ffe79c446c Implement C23 atanpi
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the atanpi functions (atan(x)/pi).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-11 21:51:49 +00:00
Joseph Myers f962932206 Implement C23 asinpi
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the asinpi functions (asin(x)/pi).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-10 20:42:20 +00:00
Joseph Myers 28d102d15c Implement C23 acospi
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the acospi functions (acos(x)/pi).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-09 23:01:29 +00:00
Joseph Myers f9e90e4b4c Implement C23 tanpi
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the tanpi functions (tan(pi*x)).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-05 21:42:10 +00:00
Adhemerval Zanella dae2e746b7 math: xfail some sinpi tests for ibm128-libgcc
On powerpc math/test-ibm128-sinpi shows:

testing long double (without inline functions)
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
Failure: Test: sinpi_downward (0x3.fffffffffffffffcp+108)
Result:
 is:          2.97479253223185882765417834495004e-15   0x1.acb679186c7b49a36c9ec63e110p-49
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  2.97479253223185882765417834495004e-15   0x1.acb679186c7b49a36c9ec63e110p-49
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  4.0000
Failure: Test: sinpi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          2.63250110604328276654475674742669e-15   0x1.7b6225fa8503a5a8c514f5c0208p-49
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  2.63250110604328276654475674742669e-15   0x1.7b6225fa8503a5a8c514f5c0208p-49
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  4.0000
Failure: Test: sinpi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
 is:         -1.71856472474338625450766636956702e-14  -0x1.3596cf230d8f69346d93d8c3100p-46
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.71856472474338625450766636956702e-14   0x1.3596cf230d8f69346d93d8c3100p-46
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  3.0000
Failure: Test: sinpi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:         -9.73792846364428462525599942305655e-15  -0x1.5ed8897ea140e96a31453d6e580p-47
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  9.73792846364428462525599942305655e-15   0x1.5ed8897ea140e96a31453d6e580p-47
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  3.0000
Failure: Test: sinpi_towardzero (0x3.fffffffffffffffcp+108)
Result:
 is:          1.71856472474338625450766636956702e-14   0x1.3596cf230d8f69346d93d8c3100p-46
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  1.71856472474338625450766636956702e-14   0x1.3596cf230d8f69346d93d8c3100p-46
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  3.0000
Failure: Test: sinpi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.73792846364428462525599942305655e-15   0x1.5ed8897ea140e96a31453d6e580p-47
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
 difference:  9.73792846364428462525599942305655e-15   0x1.5ed8897ea140e96a31453d6e580p-47
 ulp       :  179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
 max.ulp   :  3.0000
Failure: Test: sinpi_upward (-0x3.fffffffffffffffcp+108)
Result:
 is:         -1.71856472474338625450766636956709e-14  -0x1.3596cf230d8f69346d93d8c3110p-46
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  1.71856472474338625450766636956710e-14   0x1.3596cf230d8f69346d93d8c3110p-46
 ulp       :  inf
 max.ulp   :  4.0000
Failure: Test: sinpi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:         -9.73792846364428462525599942305708e-15  -0x1.5ed8897ea140e96a31453d6e598p-47
 should be:  -0.00000000000000000000000000000000e+00  -0x0.000000000000000000000000000p+0
 difference:  9.73792846364428462525599942305709e-15   0x1.5ed8897ea140e96a31453d6e598p-47
 ulp       :  inf
 max.ulp   :  4.0000
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:   0.00000000000000000000000000000000e+00   0x0.000000000000000000000000000p+0
2024-12-05 13:48:01 -03:00
Adhemerval Zanella b14224fb57 math: xfail some cospi tests for ibm128-libgcc
On powerpc math/test-ibm128-cospi shows:

testing long double (without inline functions)
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
Failure: Test: cospi_downward (0x3.fffffffffffffffcp+108)
Result:
 is:          9.99999999999999999999999999995574e-01   0x1.ffffffffffffffffffffffff4c8p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  4.42501664022411309598141492088312e-30   0x1.670000000000000000000000000p-98
 ulp       :  179.5000
 max.ulp   :  4.0000
Failure: Test: cospi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.99999999999999999999999999996524e-01   0x1.ffffffffffffffffffffffff730p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  3.47591836363008326759542899077727e-30   0x1.1a0000000000000000000000000p-98
 ulp       :  141.0000
 max.ulp   :  4.0000
Failure: Test: cospi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
 is:          9.99999999999999999999999999852310e-01   0x1.ffffffffffffffffffffffe8990p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.47689552599346303944427057331536e-28   0x1.767000000000000000000000000p-93
 ulp       :  5991.0000
 max.ulp   :  4.0000
Failure: Test: cospi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.99999999999999999999999999952569e-01   0x1.fffffffffffffffffffffff87c0p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  4.74302619264133348003801799876275e-29   0x1.e10000000000000000000000000p-95
 ulp       :  1924.0000
 max.ulp   :  4.0000
Failure: Test: cospi_towardzero (0x3.fffffffffffffffcp+108)
Result:
 is:          9.99999999999999999999999999852310e-01   0x1.ffffffffffffffffffffffe8990p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.47689552599346303944427057331536e-28   0x1.767000000000000000000000000p-93
 ulp       :  5991.0000
 max.ulp   :  4.0000
Failure: Test: cospi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.99999999999999999999999999952569e-01   0x1.fffffffffffffffffffffff87c0p-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  4.74302619264133348003801799876275e-29   0x1.e10000000000000000000000000p-95
 ulp       :  1924.0000
 max.ulp   :  4.0000
Failure: Test: cospi_upward (-0x3.fffffffffffffffcp+108)
Result:
 is:          9.99999999999999999999999999852323e-01   0x1.ffffffffffffffffffffffe899bp-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  1.47673235656615530277812119019587e-28   0x1.766568e20369c00000000000000p-93
 ulp       :  5990.3382
 max.ulp   :  4.0000
Failure: Test: cospi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
 is:          9.99999999999999999999999999952583e-01   0x1.fffffffffffffffffffffff87cbp-1
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
 difference:  4.74136253815267677203679334037676e-29   0x1.e0d4cf1e9076600000000000000p-95
 ulp       :  1923.3252
 max.ulp   :  4.0000
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
 is:         qNaN
 should be:   1.00000000000000000000000000000000e+00   0x1.000000000000000000000000000p+0
2024-12-05 13:47:52 -03:00
Joseph Myers 30ad01a3cf Use M_LIT in place of M_MLIT for literals
This should fix the reported issue building cospi and sinpi with GCC 6.

Tested for x86_64 (not with GCC 6).
2024-12-05 10:12:09 +00:00
H.J. Lu 00de38e531 Fix and sort variables in Makefiles
Fix variables in Makefiles:

1. There is a tab, not a space, between "variable" and =, +=, :=.
2. The last entry doesn't have a trailing \.

and sort them.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-12-05 15:36:23 +08:00
Joseph Myers 776938e8b8 Implement C23 sinpi
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the sinpi functions (sin(pi*x)).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-04 20:04:04 +00:00
Joseph Myers 0ae0af68d8 Implement C23 cospi
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the cospi functions (cos(pi*x)).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-12-04 10:20:44 +00:00
Adhemerval Zanella c4c64ba5d1 math: Split s_erfF in erff and erfc
So we can eventually replace each implementation.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-11-22 10:52:26 -03:00
Paul Zimmermann 392b3f0971 replace tgammaf by the CORE-MATH implementation
The CORE-MATH implementation is correctly rounded (for any rounding mode).
This can be checked by exhaustive tests in a few minutes since there are
less than 2^32 values to check against for example GNU MPFR.
This patch also adds some bench values for tgammaf.

Tested on x86_64 and x86 (cfarm26).

With the initial GNU libc code it gave on an Intel(R) Core(TM) i7-8700:

      "tgammaf": {
       "": {
        "duration": 3.50188e+09,
        "iterations": 2e+07,
        "max": 602.891,
        "min": 65.1415,
        "mean": 175.094
       }
      }

With the new code:

      "tgammaf": {
       "": {
        "duration": 3.30825e+09,
        "iterations": 5e+07,
        "max": 211.592,
        "min": 32.0325,
        "mean": 66.1649
       }
      }

With the initial GNU libc code it gave on cfarm26 (i686):

  "tgammaf": {
   "": {
    "duration": 3.70505e+09,
    "iterations": 6e+06,
    "max": 2420.23,
    "min": 243.154,
    "mean": 617.509
   }
  }

With the new code:

  "tgammaf": {
   "": {
    "duration": 3.24497e+09,
    "iterations": 1.8e+07,
    "max": 1238.15,
    "min": 101.155,
    "mean": 180.276
   }
  }

Signed-off-by: Alexei Sibidanov <sibid@uvic.ca>
Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>

Changes in v2:
    - include <math.h> (fix the linknamespace failures)
    - restored original benchtests/strcoll-inputs/filelist#en_US.UTF-8 file
    - restored original wrapper code (math/w_tgammaf_compat.c),
      except for the dealing with the sign
    - removed the tgammaf/float entries in all libm-test-ulps files
    - address other comments from Joseph Myers
      (https://sourceware.org/pipermail/libc-alpha/2024-July/158736.html)

Changes in v3:
    - pass NULL argument for signgam from w_tgammaf_compat.c
    - use of math_narrow_eval
    - added more comments

Changes in v4:
    - initialize local_signgam to 0 in math/w_tgamma_template.c
    - replace sysdeps/ieee754/dbl-64/gamma_productf.c by dummy file

Changes in v5:
    - do not mention local_signgam any more in math/w_tgammaf_compat.c
    - initialize local_signgam to 1 instead of 0 in w_tgamma_template.c
      and added comment

Changes in v6:
    - pass NULL as 2nd argument of __ieee754_gammaf_r in
      w_tgammaf_compat.c, and check for NULL in e_gammaf_r.c

Changes in v7:
    - added Signed-off-by line for Alexei Sibidanov (author of the code)

Changes in v8:
    - added Signed-off-by line for Paul Zimmermann (submitted of the patch)

Changes in v9:
    - address comments from review by Adhemerval Zanella
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-10-11 11:12:32 +02:00
Joe Ramsay 751a5502be AArch64: Add vector logp1 alias for log1p
This enables vectorisation of C23 logp1, which is an alias for log1p.
There are no new tests or ulp entries because the new symbols are simply
aliases.

Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
2024-09-19 17:53:34 +01:00
Joseph Myers 64f62c47e9 Do not set errno for overflowing NaN payload in strtod/nan (bug 32045)
As reported in bug 32045, it's incorrect for strtod/nan functions to
set errno based on overflowing payload (strtod should only set errno
for overflow / underflow of its actual result, and potentially if
nothing in the string can be parsed as a number at all; nan should be
a pure function that never sets it).  Save and restore errno around
the internal strtoull call and add associated test coverage.

Tested for x86_64.
2024-09-04 13:21:23 +00:00
Joseph Myers be77d5ae41 Improve NaN payload testing
There are two separate sets of tests of NaN payloads in glibc:

* libm-test-{get,set}payload* verify that getpayload, setpayload,
  setpayloadsig and __builtin_nan functions are consistent in their
  payload handling.

* test-nan-payload verifies that strtod-family functions and the
  not-built-in nan functions are consistent in their payload handling.

Nothing, however, connects the two sets of functions (i.e., verifies
that strtod / nan are consistent with getpayload / setpayload /
__builtin_nan).

Improve test-nan-payload to check actual payload value with getpayload
rather than just verifying that the strtod and nan functions produce
the same NaN.  Also check that the NaNs produced aren't signaling and
extend the tests to cover _FloatN / _FloatNx.

Tested for x86_64.
2024-09-04 13:20:18 +00:00
Paul Zimmermann 0797283910 added inputs giving large errors on x86_64 for new C23 functions
These functions are exp10m1, exp2m1, log10p1, log2p1.
Also regenerated ulps on x86_64.

For each format, there are 4 values, one for each rounding mode.
(For the intel96 format, there are 8 values, 4 for Intel hardware,
and 4 for AMD hardware. However, regen-ulps was only run on Intel.
It should be run in a separate patch on a AMD x86_64.)
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-08-07 14:28:46 +02:00
Maciej W. Rozycki 1b97a9f23b support: Add FAIL test failure helper
Add a FAIL test failure helper analogous to FAIL_RET, that does not
cause the current function to return, providing a standardized way to
report a test failure with a message supplied while permitting the
caller to continue executing, for further reporting, cleaning up, etc.

Update existing test cases that provide a conflicting definition of FAIL
by removing the local FAIL definition and then as follows:

- tst-fortify-syslog: provide a meaningful message in addition to the
  file name already added by <support/check.h>; 'support_record_failure'
  is already called by 'support_print_failure_impl' invoked by the new
  FAIL test failure helper.

- tst-ctype: no update to FAIL calls required, with the name of the file
  and the line number within of the failure site additionally included
  by the new FAIL test failure helper, and error counting plus count
  reporting upon test program termination also already provided by
  'support_record_failure' and 'support_report_failure' respectively,
  called by 'support_print_failure_impl' and 'adjust_exit_status' also
  respectively.  However in a number of places 'printf' is called and
  the error count adjusted by hand, so update these places to make use
  of FAIL instead.  And last but not least adjust the final summary just
  to report completion, with any error count following as reported by
  the test driver.

- test-tgmath2: no update to FAIL calls required, with the name of the
  file of the failure site additionally included by the new FAIL test
  failure helper.  Also there is no need to track the return status by
  hand as any call to FAIL will eventually cause the test case to return
  an unsuccesful exit status regardless of the return status from the
  test function, via a call to 'adjust_exit_status' made by the test
  driver.

Reviewed-by: DJ Delorie <dj@redhat.com>
2024-07-26 13:21:34 +01:00
Paul Zimmermann 4dc22baa84 This patch adds larger ulp errors for the log2p1 function.
Changes in v2:
- added larger error for long double on AMD reported by Adhemerval
  (https://sourceware.org/pipermail/libc-alpha/2024-June/157755.html)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2024-07-22 08:54:23 +02:00
Joseph Myers 7ec903e028 Implement C23 exp2m1, exp10m1
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the exp2m1 and exp10m1 functions (exp2(x)-1 and
exp10(x)-1, like expm1).

As with other such functions, these use type-generic templates that
could be replaced with faster and more accurate type-specific
implementations in future.  Test inputs are copied from those for
expm1, plus some additions close to the overflow threshold (copied
from exp2 and exp10) and also some near the underflow threshold.

exp2m1 has the unusual property of having an input (M_MAX_EXP) where
whether the function overflows (under IEEE semantics) depends on the
rounding mode.  Although these could reasonably be XFAILed in the
testsuite (as we do in some cases for arguments very close to a
function's overflow threshold when an error of a few ulps in the
implementation can result in the implementation not agreeing with an
ideal one on whether overflow takes place - the testsuite isn't smart
enough to handle this automatically), since these functions aren't
required to be correctly rounding, I made the implementation check for
and handle this case specially.

The Makefile ordering expected by lint-makefiles for the new functions
is a bit peculiar, but I implemented it in this patch so that the test
passes; I don't know why log2 also needed moving in one Makefile
variable setting when it didn't in my previous patches, but the
failure showed a different place was expected for that function as
well.

The powerpc64le IFUNC setup seems not to be as self-contained as one
might hope; it shouldn't be necessary to add IFUNCs for new functions
such as these simply to get them building, but without setting up
IFUNCs for the new functions, there were undefined references to
__GI___expm1f128 (that IFUNC machinery results in no such function
being defined, but doesn't stop include/math.h from doing the
redirection resulting in the exp2m1f128 and exp10m1f128
implementations expecting to call it).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-06-17 16:31:49 +00:00
Joseph Myers 55eb99e9a9 Implement C23 log10p1
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the log10p1 functions (log10(1+x): like log1p, but for
base-10 logarithms).

This is directly analogous to the log2p1 implementation (except that
whereas log2p1 has a smaller underflow range than log1p, log10p1 has a
larger underflow range).  The test inputs are copied from those for
log1p and log2p1, plus a few more inputs in that wider underflow
range.

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-06-17 13:48:13 +00:00
Joseph Myers bb014f50c4 Implement C23 logp1
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the logp1 functions (aliases for log1p functions - the
name is intended to be more consistent with the new log2p1 and
log10p1, where clearly it would have been very confusing to name those
functions log21p and log101p).  As aliases rather than new functions,
the content of this patch is somewhat different from those actually
adding new functions.

Tests are shared with log1p, so this patch *does* mechanically update
all affected libm-test-ulps files to expect the same errors for both
functions.

The vector versions of log1p on aarch64 and x86_64 are *not* updated
to have logp1 aliases (and thus there are no corresponding header,
tests, abilist or ulps changes for vector functions either).  It would
be reasonable for such vector aliases and corresponding changes to
other files to be made separately.  For now, the log1p tests instead
avoid testing logp1 in the vector case (a Makefile change is needed to
avoid problems with grep, used in generating the .c files for vector
function tests, matching more than one ALL_RM_TEST line in a file
testing multiple functions with the same inputs, when it assumes that
the .inc file only has a single such line).

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-06-17 13:47:09 +00:00
H.J. Lu a34f76edbd Don't provide scalb/significand _FloatN aliases [BZ #31760]
scalb is a deprecated interface which was obsolescent in POSIX.1-2001,
removed in POSIX.1-2008, never made to C standard.  significant was
originally from BSD and never made in any standard.  Fix BZ #31760 by
not providing _FloatN aliases for them.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-05-22 06:10:54 -07:00
Adhemerval Zanella ce6cdb94d0 math: Add support for auto static math tests
It basically copy the already in place rules for dynamic tests for
auto-generated math functions for all support types.  To avoid the
need to duplicate .inc files, a .SECONDEXPANSION rules is adeed for
the gen-libm-test.py generation.

New tests are added on the new rules 'libm-test-funcs-auto-static',
'libm-test-funcs-noauto-static', and 'libm-test-funcs-narrow-static';
similar to the non-static counterparts.

To avoid add extra build and disk requirement, the new math static
tests are only enable with a new define 'build-math-static-tests'.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-05-21 16:53:27 -03:00
Joe Simmons-Talbott ae18044f95 math: Add more details to the test driver output.
Add start and end indicators that identify the test being run in the
verbose output.  Better identify the tests for max errors in the
summary output.  Count each exception checked for each test. Remove
double counting of tests for the check_<type> functions other than
check_float_internal. Rename print_max_error and
print_complex_max_error to check_max_error and check_complex_max_error
respectively since they have side effects.

Co-Authored-By: Carlos O'Donell <carlos@redhat.com>
Reviewed-By: Joseph Myers <josmyers@redhat.com>
2024-05-20 14:09:54 +00:00
Joseph Myers 79c52daf47 Implement C23 log2p1
C23 adds various <math.h> function families originally defined in TS
18661-4.  Add the log2p1 functions (log2(1+x): like log1p, but for
base-2 logarithms).

This illustrates the intended structure of implementations of all
these function families: define them initially with a type-generic
template implementation.  If someone wishes to add type-specific
implementations, it is likely such implementations can be both faster
and more accurate than the type-generic one and can then override it
for types for which they are implemented (adding benchmarks would be
desirable in such cases to demonstrate that a new implementation is
indeed faster).

The test inputs are copied from those for log1p.  Note that these
changes make gen-auto-libm-tests depend on MPFR 4.2 (or later).

The bulk of the changes are fairly generic for any such new function.
(sysdeps/powerpc/nofpu/Makefile only needs changing for those
type-generic templates that use fabs.)

Tested for x86_64 and x86, and with build-many-glibcs.py.
2024-05-20 13:41:39 +00:00
Joe Talbott f942a732d3 math: Add GLIBC_TEST_LIBM_VERBOSE environment variable support.
Allow the libm-test-driver based tests to have their verbosity set based
on the GLIBC_TEST_LIBM_VERBOSE environment variable.  This allows the entire
testsuite to be run with a non-default verbosity.

While here check the conversion for the verbose option as well.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-05-14 14:39:38 +00:00
H.J. Lu 5f245f3bfb Add crt1-2.0.o for glibc 2.0 compatibility tests
Starting from glibc 2.1, crt1.o contains _IO_stdin_used which is checked
by _IO_check_libio to provide binary compatibility for glibc 2.0.  Add
crt1-2.0.o for tests against glibc 2.0.  Define tests-2.0 for glibc 2.0
compatibility tests.  Add and update glibc 2.0 compatibility tests for
stderr, matherr and pthread_kill.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2024-05-06 07:49:40 -07:00
Adhemerval Zanella 44ccc2465c math: x86 trunc traps when FE_INEXACT is enabled (BZ 31603)
The implementations of trunc functions using x87 floating point (i386 and
x86_64 long double only) traps when FE_INEXACT is enabled.  Although
this is a GNU extension outside the scope of the C standard, other
architectures that also support traps do not show this behavior.

The fix moves the implementation to a common one that holds any
exceptions with a 'fnclex' (libc_feholdexcept_setround_387).

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-04-04 14:29:28 -03:00
Adhemerval Zanella 932544efa4 math: x86 floor traps when FE_INEXACT is enabled (BZ 31601)
The implementations of floor functions using x87 floating point (i386 and
86_64 long double only) traps when FE_INEXACT is enabled.  Although
this is a GNU extension outside the scope of the C standard, other
architectures that also support traps do not show this behavior.

The fix moves the implementation to a common one that holds any
exceptions with a 'fnclex' (libc_feholdexcept_setround_387).

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-04-04 14:29:28 -03:00
Adhemerval Zanella 637bfc392f math: x86 ceill traps when FE_INEXACT is enabled (BZ 31600)
The implementations of ceil functions using x87 floating point (i386 and
x86_64 long double only) traps when FE_INEXACT is enabled.  Although
this is a GNU extension outside the scope of the C standard, other
architectures that also support traps do not show this behavior.

The fix moves the implementation to a common one that holds any
exceptions with a 'fnclex' (libc_feholdexcept_setround_387).

Checked on x86_64-linux-gnu and i686-linux-gnu.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-04-04 14:29:28 -03:00
Joe Ramsay 3d3a4fb8e4 aarch64/fpu: Add vector variants of tanh
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2024-04-04 10:33:20 +01:00
Adhemerval Zanella c0d59e3e0d math: Reformat Makefile.
Reflow all long lines adding comment terminators.
Sort all reflowed text using scripts/sort-makefile-lines.py.

No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
2024-04-02 15:49:20 -03:00
Konstantin Kharlamov fe00366b63 treewide: python-scripts: use `is None` for none-equality
Testing for `None`-ness with `==` operator is frowned upon and causes
warnings in at least "LGTM" python linter. Fix that.

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2024-02-23 08:50:00 -03:00
Adhemerval Zanella 9c61303ebb math: Remove bogus math implementations
The exp10, exp10l, fma, fmaf, and fmal default implementation do not
implement the appropriate semantics nor with an reasonable accuracy.
They are also not used by any supported port.
2024-02-01 09:31:33 -03:00