diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2024-11-19 13:31:14 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2024-12-18 17:24:43 -0300 |
commit | 7cfd8b56982a88511e62241346b23d611f822793 (patch) | |
tree | 43082cf9f0d2b13da5b43747511b8e8e2a71df6c /sysdeps/i386/fpu | |
parent | 6f9bacf36b20b1a87fa4ec24c9d67c47985fbc8b (diff) | |
download | glibc-7cfd8b56982a88511e62241346b23d611f822793.zip glibc-7cfd8b56982a88511e62241346b23d611f822793.tar.gz glibc-7cfd8b56982a88511e62241346b23d611f822793.tar.bz2 |
math: Use atanhf from CORE-MATH
The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows slight better performance to the generic atanhf.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).
Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):
Latency master patched improvement
x86_64 59.4930 45.8568 22.92%
x86_64v2 59.5705 45.5804 23.48%
x86_64v3 53.1838 37.7155 29.08%
i686 169.354 133.5940 21.12%
aarch64 (Neoverse) 26.0781 16.9829 34.88%
power10 15.6591 10.7623 31.27%
reciprocal-throughput master patched improvement
x86_64 23.5903 18.5766 21.25%
x86_64v2 22.6489 18.2683 19.34%
x86_64v3 19.0401 13.9474 26.75%
i686 97.6034 107.3260 -9.96%
aarch64 (Neoverse) 15.3664 9.57846 37.67%
power10 6.8877 4.6242 32.86%
Signed-off-by: Alexei Sibidanov <sibid@uvic.ca>
Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'sysdeps/i386/fpu')
-rw-r--r-- | sysdeps/i386/fpu/e_atanhf.S | 110 | ||||
-rw-r--r-- | sysdeps/i386/fpu/libm-test-ulps | 3 |
2 files changed, 0 insertions, 113 deletions
diff --git a/sysdeps/i386/fpu/e_atanhf.S b/sysdeps/i386/fpu/e_atanhf.S deleted file mode 100644 index c94dc7b..0000000 --- a/sysdeps/i386/fpu/e_atanhf.S +++ /dev/null @@ -1,110 +0,0 @@ -/* ix87 specific implementation of arctanh function. - Copyright (C) 1996-2024 Free Software Foundation, Inc. - This file is part of the GNU C Library. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library; if not, see - <https://www.gnu.org/licenses/>. */ - -#include <machine/asm.h> -#include <i386-math-asm.h> -#include <libm-alias-finite.h> - - .section .rodata - - .align ALIGNARG(4) - .type half,@object -half: .double 0.5 - ASM_SIZE_DIRECTIVE(half) - .type one,@object -one: .double 1.0 - ASM_SIZE_DIRECTIVE(one) - .type limit,@object -limit: .double 0.29 - ASM_SIZE_DIRECTIVE(limit) - .align ALIGNARG(4) - .type ln2_2,@object -ln2_2: .quad 0xb17217f7d1cf79ac /* 0.3465735902799726547086160 */ - .short 0x3ffd - ASM_SIZE_DIRECTIVE(ln2_2) - -DEFINE_FLT_MIN - -#ifdef PIC -#define MO(op) op##@GOTOFF(%edx) -#else -#define MO(op) op -#endif - - .text -ENTRY(__ieee754_atanhf) - movl 4(%esp), %ecx - - movl %ecx, %eax - andl $0x7fffffff, %eax - cmpl $0x7f800000, %eax - ja 5f - -#ifdef PIC - LOAD_PIC_REG (dx) -#endif - - andl $0x80000000, %ecx // ECX == 0 iff X >= 0 - - fldt MO(ln2_2) // 0.5*ln2 - xorl %ecx, 4(%esp) - flds 4(%esp) // |x| : 0.5*ln2 - fcoml MO(half) // |x| : 0.5*ln2 - fld %st(0) // |x| : |x| : 0.5*ln2 - fnstsw // |x| : |x| : 0.5*ln2 - sahf - jae 2f - fadd %st, %st(1) // |x| : 2*|x| : 0.5*ln2 - fld %st // |x| : |x| : 2*|x| : 0.5*ln2 - fsubrl MO(one) // 1-|x| : |x| : 2*|x| : 0.5*ln2 - fxch // |x| : 1-|x| : 2*|x| : 0.5*ln2 - fmul %st(2) // 2*|x|^2 : 1-|x| : 2*|x| : 0.5*ln2 - fdivp // (2*|x|^2)/(1-|x|) : 2*|x| : 0.5*ln2 - faddp // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2 - fcoml MO(limit) // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2 - fnstsw // 2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2 - sahf - jae 4f - fyl2xp1 // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|)) - FLT_CHECK_FORCE_UFLOW_NONNEG - jecxz 3f - fchs // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x)) -3: ret - - .align ALIGNARG(4) -4: faddl MO(one) // 1+2*|x|+(2*|x|^2)/(1-|x|) : 0.5*ln2 - fyl2x // 0.5*ln2*ld(1+2*|x|+(2*|x|^2)/(1-|x|)) - jecxz 3f - fchs // 0.5*ln2*ld(1+2*x+(2*x^2)/(1-x)) -3: ret - - .align ALIGNARG(4) -2: faddl MO(one) // 1+|x| : |x| : 0.5*ln2 - fxch // |x| : 1+|x| : 0.5*ln2 - fsubrl MO(one) // 1-|x| : 1+|x| : 0.5*ln2 - fdivrp // (1+|x|)/(1-|x|) : 0.5*ln2 - fyl2x // 0.5*ln2*ld((1+|x|)/(1-|x|)) - jecxz 3f - fchs // 0.5*ln2*ld((1+x)/(1-x)) -3: ret - - // x == NaN -5: flds 4(%esp) - ret -END(__ieee754_atanhf) -libm_alias_finite (__ieee754_atanhf, __atanhf) diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 3c16d88..de9b783 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -198,19 +198,16 @@ ldouble: 3 Function: "atanh_downward": double: 1 -float: 1 float128: 4 ldouble: 4 Function: "atanh_towardzero": double: 1 -float: 1 float128: 2 ldouble: 3 Function: "atanh_upward": double: 1 -float: 1 float128: 4 ldouble: 5 |