diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2024-10-25 15:21:49 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2024-11-01 11:27:35 -0300 |
commit | bbd578b38df4ef417acc9af332fa2ddbb4952df4 (patch) | |
tree | cc71c3652b5d47db815a62283c1633b21c946163 /sysdeps/i386/fpu | |
parent | 5c22fd25c15ff56583ca8588f137d8e59d775752 (diff) | |
download | glibc-bbd578b38df4ef417acc9af332fa2ddbb4952df4.zip glibc-bbd578b38df4ef417acc9af332fa2ddbb4952df4.tar.gz glibc-bbd578b38df4ef417acc9af332fa2ddbb4952df4.tar.bz2 |
math: Use expm1f from CORE-MATH
The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance compared to the generic expm1f.
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 96.7402 36.4026 62.37%
x86_64v2 97.5391 33.4625 65.69%
x86_64v3 82.1778 30.8668 62.44%
i686 120.58 94.8302 21.35%
aarch64 32.3558 12.8881 60.17%
power10 23.5087 9.8574 58.07%
powerpc 23.4776 9.06325 61.40%
reciprocal-throughput master patched improvement
x86_64 27.8224 15.9255 42.76%
x86_64v2 27.8364 9.6438 65.36%
x86_64v3 20.3227 9.6146 52.69%
i686 63.5629 59.4718 6.44%
aarch64 17.4838 7.1082 59.34%
power10 12.4644 8.7829 29.54%
powerpc 14.2152 5.94765 58.16%
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/libm-test-ulps | 3 | ||||
-rw-r--r-- | sysdeps/i386/fpu/s_expm1f.S | 112 |
2 files changed, 0 insertions, 115 deletions
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 98a5a53..abf9a91 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -1234,19 +1234,16 @@ ldouble: 3 Function: "expm1_downward": double: 1 -float: 1 float128: 2 ldouble: 4 Function: "expm1_towardzero": double: 1 -float: 1 float128: 4 ldouble: 4 Function: "expm1_upward": double: 1 -float: 1 float128: 3 ldouble: 4 diff --git a/sysdeps/i386/fpu/s_expm1f.S b/sysdeps/i386/fpu/s_expm1f.S deleted file mode 100644 index a1cb5bf..0000000 --- a/sysdeps/i386/fpu/s_expm1f.S +++ /dev/null @@ -1,112 +0,0 @@ -/* ix87 specific implementation of exp(x)-1. - 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/>. */ - - /* Using: e^x - 1 = 2^(x * log2(e)) - 1 */ - -#include <sysdep.h> -#include <machine/asm.h> -#include <i386-math-asm.h> -#include <libm-alias-float.h> - - .section .rodata - - .align ALIGNARG(4) - .type minus1,@object -minus1: .double -1.0 - ASM_SIZE_DIRECTIVE(minus1) - .type one,@object -one: .double 1.0 - ASM_SIZE_DIRECTIVE(one) - .type l2e,@object -l2e: .quad 0xb8aa3b295c17f0bc /* 1.442695040888963407359924681002 */ - .short 0x3fff - ASM_SIZE_DIRECTIVE(l2e) - -DEFINE_FLT_MIN - -#ifdef PIC -#define MO(op) op##@GOTOFF(%edx) -#else -#define MO(op) op -#endif - - .text -ENTRY(__expm1f) - movzwl 4+2(%esp), %eax - xorb $0x80, %ah // invert sign bit (now 1 is "positive") - cmpl $0xc2b1, %eax // is num >= 88.5? - jae HIDDEN_JUMPTARGET (__expf) - - flds 4(%esp) // x - fxam // Is NaN, +-Inf or +-0? - xorb $0x80, %ah - cmpl $0xc190, %eax // is num <= -18.0? - fstsw %ax - movb $0x45, %ch - jb 4f - - // Below -18.0 (may be -NaN or -Inf). - andb %ah, %ch -#ifdef PIC - LOAD_PIC_REG (dx) -#endif - cmpb $0x01, %ch - je 5f // If -NaN, jump. - jmp 2f // -large, possibly -Inf. - -4: // In range -18.0 to 88.5 (may be +-0 but not NaN or +-Inf). - andb %ah, %ch - cmpb $0x40, %ch - je 3f // If +-0, jump. -#ifdef PIC - LOAD_PIC_REG (dx) -#endif - -5: fldt MO(l2e) // log2(e) : x - fmulp // log2(e)*x - fld %st // log2(e)*x : log2(e)*x - // Set round-to-nearest temporarily. - subl $8, %esp - cfi_adjust_cfa_offset (8) - fstcw 4(%esp) - movl $0xf3ff, %ecx - andl 4(%esp), %ecx - movl %ecx, (%esp) - fldcw (%esp) - frndint // int(log2(e)*x) : log2(e)*x - fldcw 4(%esp) - addl $8, %esp - cfi_adjust_cfa_offset (-8) - fsubr %st, %st(1) // int(log2(e)*x) : fract(log2(e)*x) - fxch // fract(log2(e)*x) : int(log2(e)*x) - f2xm1 // 2^fract(log2(e)*x)-1 : int(log2(e)*x) - fscale // 2^(log2(e)*x)-2^int(log2(e)*x) : int(log2(e)*x) - fxch // int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x) - fldl MO(one) // 1 : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x) - fscale // 2^int(log2(e)*x) : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x) - fsubrl MO(one) // 1-2^int(log2(e)*x) : int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x) - fstp %st(1) // 1-2^int(log2(e)*x) : 2^(log2(e)*x)-2^int(log2(e)*x) - fsubrp %st, %st(1) // 2^(log2(e)*x) - FLT_CHECK_FORCE_UFLOW - ret - -2: fstp %st - fldl MO(minus1) // Set result to -1.0. -3: ret -END(__expm1f) -libm_alias_float (__expm1, expm1) |