From a8830c928540011120ac742d632ed51d52af01df Mon Sep 17 00:00:00 2001 From: Joe Ramsay Date: Thu, 16 Nov 2023 13:24:18 +0000 Subject: [PATCH] aarch64: Add vector implementations of expm1 routines May discard sign of 0 - auto tests for -0 and -0x1p-10000 updated accordingly. --- math/auto-libm-test-in | 4 +- math/auto-libm-test-out-expm1 | 212 +++++++++--------- sysdeps/aarch64/fpu/Makefile | 1 + sysdeps/aarch64/fpu/Versions | 4 + sysdeps/aarch64/fpu/bits/math-vector.h | 4 + sysdeps/aarch64/fpu/expm1_advsimd.c | 122 ++++++++++ sysdeps/aarch64/fpu/expm1_sve.c | 99 ++++++++ sysdeps/aarch64/fpu/expm1f_advsimd.c | 117 ++++++++++ sysdeps/aarch64/fpu/expm1f_sve.c | 99 ++++++++ .../fpu/test-double-advsimd-wrappers.c | 1 + .../aarch64/fpu/test-double-sve-wrappers.c | 1 + .../aarch64/fpu/test-float-advsimd-wrappers.c | 1 + sysdeps/aarch64/fpu/test-float-sve-wrappers.c | 1 + sysdeps/aarch64/libm-test-ulps | 8 + .../unix/sysv/linux/aarch64/libmvec.abilist | 4 + 15 files changed, 570 insertions(+), 108 deletions(-) create mode 100644 sysdeps/aarch64/fpu/expm1_advsimd.c create mode 100644 sysdeps/aarch64/fpu/expm1_sve.c create mode 100644 sysdeps/aarch64/fpu/expm1f_advsimd.c create mode 100644 sysdeps/aarch64/fpu/expm1f_sve.c diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index a8d6674c98..897a336469 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -5354,7 +5354,7 @@ exp2 -0x4.8ce878p-4 exp2 0xf.93d18bf7be8d272p-4 expm1 0 -expm1 -0 +expm1 -0 no-mathvec expm1 1 expm1 0.75 expm1 2 @@ -5419,7 +5419,7 @@ expm1 -0x1p-100 expm1 0x1p-600 expm1 -0x1p-600 expm1 0x1p-10000 -expm1 -0x1p-10000 +expm1 -0x1p-10000 no-mathvec expm1 0xe.4152ac57cd1ea7ap-60 expm1 0x6.660247486aed8p-4 expm1 0x6.289a78p-4 diff --git a/math/auto-libm-test-out-expm1 b/math/auto-libm-test-out-expm1 index 8483455801..91da41b7f6 100644 --- a/math/auto-libm-test-out-expm1 +++ b/math/auto-libm-test-out-expm1 @@ -23,31 +23,31 @@ expm1 0 = expm1 tonearest ibm128 0x0p+0 : 0x0p+0 : inexact-ok = expm1 towardzero ibm128 0x0p+0 : 0x0p+0 : inexact-ok = expm1 upward ibm128 0x0p+0 : 0x0p+0 : inexact-ok -expm1 -0 -= expm1 downward binary32 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest binary32 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero binary32 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward binary32 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward binary64 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest binary64 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero binary64 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward binary64 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward intel96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest intel96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero intel96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward intel96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward m68k96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest m68k96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero m68k96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward m68k96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward binary128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest binary128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero binary128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward binary128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward ibm128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest ibm128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero ibm128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward ibm128 -0x0p+0 : -0x0p+0 : inexact-ok +expm1 -0 no-mathvec += expm1 downward binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok expm1 1 = expm1 downward binary32 0x1p+0 : 0x1.b7e15p+0 : inexact-ok = expm1 tonearest binary32 0x1p+0 : 0x1.b7e152p+0 : inexact-ok @@ -1880,87 +1880,87 @@ expm1 0x1p-10000 = expm1 tonearest binary128 0x1p-10000 : 0x1p-10000 : inexact-ok = expm1 towardzero binary128 0x1p-10000 : 0x1p-10000 : inexact-ok = expm1 upward binary128 0x1p-10000 : 0x1.0000000000000000000000000001p-10000 : inexact-ok -expm1 -0x1p-10000 -= expm1 downward binary32 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest binary32 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero binary32 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward binary32 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward binary64 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest binary64 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero binary64 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward binary64 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward intel96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest intel96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero intel96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward intel96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward m68k96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest m68k96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero m68k96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward m68k96 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward binary128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest binary128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero binary128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward binary128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward ibm128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 tonearest ibm128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 towardzero ibm128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 upward ibm128 -0x0p+0 : -0x0p+0 : inexact-ok -= expm1 downward binary32 -0x8p-152 : -0x8p-152 : inexact-ok underflow errno-erange-ok -= expm1 tonearest binary32 -0x8p-152 : -0x8p-152 : inexact-ok underflow errno-erange-ok -= expm1 towardzero binary32 -0x8p-152 : -0x0p+0 : inexact-ok underflow errno-erange-ok -= expm1 upward binary32 -0x8p-152 : -0x0p+0 : inexact-ok underflow errno-erange-ok -= expm1 downward binary64 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 tonearest binary64 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 towardzero binary64 -0x8p-152 : -0x7.ffffffffffffcp-152 : inexact-ok -= expm1 upward binary64 -0x8p-152 : -0x7.ffffffffffffcp-152 : inexact-ok -= expm1 downward intel96 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 tonearest intel96 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 towardzero intel96 -0x8p-152 : -0x7.fffffffffffffff8p-152 : inexact-ok -= expm1 upward intel96 -0x8p-152 : -0x7.fffffffffffffff8p-152 : inexact-ok -= expm1 downward m68k96 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 tonearest m68k96 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 towardzero m68k96 -0x8p-152 : -0x7.fffffffffffffff8p-152 : inexact-ok -= expm1 upward m68k96 -0x8p-152 : -0x7.fffffffffffffff8p-152 : inexact-ok -= expm1 downward binary128 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 tonearest binary128 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 towardzero binary128 -0x8p-152 : -0x7.fffffffffffffffffffffffffffcp-152 : inexact-ok -= expm1 upward binary128 -0x8p-152 : -0x7.fffffffffffffffffffffffffffcp-152 : inexact-ok -= expm1 downward ibm128 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 tonearest ibm128 -0x8p-152 : -0x8p-152 : inexact-ok -= expm1 towardzero ibm128 -0x8p-152 : -0x7.fffffffffffffffffffffffffep-152 : inexact-ok -= expm1 upward ibm128 -0x8p-152 : -0x7.fffffffffffffffffffffffffep-152 : inexact-ok -= expm1 downward binary64 -0x4p-1076 : -0x4p-1076 : inexact-ok underflow errno-erange-ok -= expm1 tonearest binary64 -0x4p-1076 : -0x4p-1076 : inexact-ok underflow errno-erange-ok -= expm1 towardzero binary64 -0x4p-1076 : -0x0p+0 : inexact-ok underflow errno-erange-ok -= expm1 upward binary64 -0x4p-1076 : -0x0p+0 : inexact-ok underflow errno-erange-ok -= expm1 downward intel96 -0x4p-1076 : -0x4p-1076 : inexact-ok -= expm1 tonearest intel96 -0x4p-1076 : -0x4p-1076 : inexact-ok -= expm1 towardzero intel96 -0x4p-1076 : -0x3.fffffffffffffffcp-1076 : inexact-ok -= expm1 upward intel96 -0x4p-1076 : -0x3.fffffffffffffffcp-1076 : inexact-ok -= expm1 downward m68k96 -0x4p-1076 : -0x4p-1076 : inexact-ok -= expm1 tonearest m68k96 -0x4p-1076 : -0x4p-1076 : inexact-ok -= expm1 towardzero m68k96 -0x4p-1076 : -0x3.fffffffffffffffcp-1076 : inexact-ok -= expm1 upward m68k96 -0x4p-1076 : -0x3.fffffffffffffffcp-1076 : inexact-ok -= expm1 downward binary128 -0x4p-1076 : -0x4p-1076 : inexact-ok -= expm1 tonearest binary128 -0x4p-1076 : -0x4p-1076 : inexact-ok -= expm1 towardzero binary128 -0x4p-1076 : -0x3.fffffffffffffffffffffffffffep-1076 : inexact-ok -= expm1 upward binary128 -0x4p-1076 : -0x3.fffffffffffffffffffffffffffep-1076 : inexact-ok -= expm1 downward ibm128 -0x4p-1076 : -0x4p-1076 : xfail:ibm128-libgcc inexact-ok underflow errno-erange-ok -= expm1 tonearest ibm128 -0x4p-1076 : -0x4p-1076 : inexact-ok underflow errno-erange-ok -= expm1 towardzero ibm128 -0x4p-1076 : -0x0p+0 : xfail:ibm128-libgcc inexact-ok underflow errno-erange-ok -= expm1 upward ibm128 -0x4p-1076 : -0x0p+0 : xfail:ibm128-libgcc inexact-ok underflow errno-erange-ok -= expm1 downward intel96 -0x1p-10000 : -0x1p-10000 : inexact-ok -= expm1 tonearest intel96 -0x1p-10000 : -0x1p-10000 : inexact-ok -= expm1 towardzero intel96 -0x1p-10000 : -0xf.fffffffffffffffp-10004 : inexact-ok -= expm1 upward intel96 -0x1p-10000 : -0xf.fffffffffffffffp-10004 : inexact-ok -= expm1 downward m68k96 -0x1p-10000 : -0x1p-10000 : inexact-ok -= expm1 tonearest m68k96 -0x1p-10000 : -0x1p-10000 : inexact-ok -= expm1 towardzero m68k96 -0x1p-10000 : -0xf.fffffffffffffffp-10004 : inexact-ok -= expm1 upward m68k96 -0x1p-10000 : -0xf.fffffffffffffffp-10004 : inexact-ok -= expm1 downward binary128 -0x1p-10000 : -0x1p-10000 : inexact-ok -= expm1 tonearest binary128 -0x1p-10000 : -0x1p-10000 : inexact-ok -= expm1 towardzero binary128 -0x1p-10000 : -0xf.fffffffffffffffffffffffffff8p-10004 : inexact-ok -= expm1 upward binary128 -0x1p-10000 : -0xf.fffffffffffffffffffffffffff8p-10004 : inexact-ok +expm1 -0x1p-10000 no-mathvec += expm1 downward binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward binary32 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward binary64 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward intel96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward m68k96 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward binary128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 tonearest ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 towardzero ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 upward ibm128 -0x0p+0 : -0x0p+0 : no-mathvec inexact-ok += expm1 downward binary32 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 tonearest binary32 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 towardzero binary32 -0x8p-152 : -0x0p+0 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 upward binary32 -0x8p-152 : -0x0p+0 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 downward binary64 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 tonearest binary64 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 towardzero binary64 -0x8p-152 : -0x7.ffffffffffffcp-152 : no-mathvec inexact-ok += expm1 upward binary64 -0x8p-152 : -0x7.ffffffffffffcp-152 : no-mathvec inexact-ok += expm1 downward intel96 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 tonearest intel96 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 towardzero intel96 -0x8p-152 : -0x7.fffffffffffffff8p-152 : no-mathvec inexact-ok += expm1 upward intel96 -0x8p-152 : -0x7.fffffffffffffff8p-152 : no-mathvec inexact-ok += expm1 downward m68k96 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 tonearest m68k96 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 towardzero m68k96 -0x8p-152 : -0x7.fffffffffffffff8p-152 : no-mathvec inexact-ok += expm1 upward m68k96 -0x8p-152 : -0x7.fffffffffffffff8p-152 : no-mathvec inexact-ok += expm1 downward binary128 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 tonearest binary128 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 towardzero binary128 -0x8p-152 : -0x7.fffffffffffffffffffffffffffcp-152 : no-mathvec inexact-ok += expm1 upward binary128 -0x8p-152 : -0x7.fffffffffffffffffffffffffffcp-152 : no-mathvec inexact-ok += expm1 downward ibm128 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 tonearest ibm128 -0x8p-152 : -0x8p-152 : no-mathvec inexact-ok += expm1 towardzero ibm128 -0x8p-152 : -0x7.fffffffffffffffffffffffffep-152 : no-mathvec inexact-ok += expm1 upward ibm128 -0x8p-152 : -0x7.fffffffffffffffffffffffffep-152 : no-mathvec inexact-ok += expm1 downward binary64 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 tonearest binary64 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 towardzero binary64 -0x4p-1076 : -0x0p+0 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 upward binary64 -0x4p-1076 : -0x0p+0 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 downward intel96 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok += expm1 tonearest intel96 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok += expm1 towardzero intel96 -0x4p-1076 : -0x3.fffffffffffffffcp-1076 : no-mathvec inexact-ok += expm1 upward intel96 -0x4p-1076 : -0x3.fffffffffffffffcp-1076 : no-mathvec inexact-ok += expm1 downward m68k96 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok += expm1 tonearest m68k96 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok += expm1 towardzero m68k96 -0x4p-1076 : -0x3.fffffffffffffffcp-1076 : no-mathvec inexact-ok += expm1 upward m68k96 -0x4p-1076 : -0x3.fffffffffffffffcp-1076 : no-mathvec inexact-ok += expm1 downward binary128 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok += expm1 tonearest binary128 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok += expm1 towardzero binary128 -0x4p-1076 : -0x3.fffffffffffffffffffffffffffep-1076 : no-mathvec inexact-ok += expm1 upward binary128 -0x4p-1076 : -0x3.fffffffffffffffffffffffffffep-1076 : no-mathvec inexact-ok += expm1 downward ibm128 -0x4p-1076 : -0x4p-1076 : no-mathvec xfail:ibm128-libgcc inexact-ok underflow errno-erange-ok += expm1 tonearest ibm128 -0x4p-1076 : -0x4p-1076 : no-mathvec inexact-ok underflow errno-erange-ok += expm1 towardzero ibm128 -0x4p-1076 : -0x0p+0 : no-mathvec xfail:ibm128-libgcc inexact-ok underflow errno-erange-ok += expm1 upward ibm128 -0x4p-1076 : -0x0p+0 : no-mathvec xfail:ibm128-libgcc inexact-ok underflow errno-erange-ok += expm1 downward intel96 -0x1p-10000 : -0x1p-10000 : no-mathvec inexact-ok += expm1 tonearest intel96 -0x1p-10000 : -0x1p-10000 : no-mathvec inexact-ok += expm1 towardzero intel96 -0x1p-10000 : -0xf.fffffffffffffffp-10004 : no-mathvec inexact-ok += expm1 upward intel96 -0x1p-10000 : -0xf.fffffffffffffffp-10004 : no-mathvec inexact-ok += expm1 downward m68k96 -0x1p-10000 : -0x1p-10000 : no-mathvec inexact-ok += expm1 tonearest m68k96 -0x1p-10000 : -0x1p-10000 : no-mathvec inexact-ok += expm1 towardzero m68k96 -0x1p-10000 : -0xf.fffffffffffffffp-10004 : no-mathvec inexact-ok += expm1 upward m68k96 -0x1p-10000 : -0xf.fffffffffffffffp-10004 : no-mathvec inexact-ok += expm1 downward binary128 -0x1p-10000 : -0x1p-10000 : no-mathvec inexact-ok += expm1 tonearest binary128 -0x1p-10000 : -0x1p-10000 : no-mathvec inexact-ok += expm1 towardzero binary128 -0x1p-10000 : -0xf.fffffffffffffffffffffffffff8p-10004 : no-mathvec inexact-ok += expm1 upward binary128 -0x1p-10000 : -0xf.fffffffffffffffffffffffffff8p-10004 : no-mathvec inexact-ok expm1 0xe.4152ac57cd1ea7ap-60 = expm1 downward binary32 0xe.4152bp-60 : 0xe.4152bp-60 : inexact-ok = expm1 tonearest binary32 0xe.4152bp-60 : 0xe.4152bp-60 : inexact-ok diff --git a/sysdeps/aarch64/fpu/Makefile b/sysdeps/aarch64/fpu/Makefile index c77c709edd..1fe4b52682 100644 --- a/sysdeps/aarch64/fpu/Makefile +++ b/sysdeps/aarch64/fpu/Makefile @@ -6,6 +6,7 @@ libmvec-supported-funcs = acos \ exp \ exp10 \ exp2 \ + expm1 \ log \ log10 \ log1p \ diff --git a/sysdeps/aarch64/fpu/Versions b/sysdeps/aarch64/fpu/Versions index 2543649fbe..aaacacaebe 100644 --- a/sysdeps/aarch64/fpu/Versions +++ b/sysdeps/aarch64/fpu/Versions @@ -42,6 +42,10 @@ libmvec { _ZGVnN2v_exp2; _ZGVsMxv_exp2f; _ZGVsMxv_exp2; + _ZGVnN4v_expm1f; + _ZGVnN2v_expm1; + _ZGVsMxv_expm1f; + _ZGVsMxv_expm1; _ZGVnN4v_log10f; _ZGVnN2v_log10; _ZGVsMxv_log10f; diff --git a/sysdeps/aarch64/fpu/bits/math-vector.h b/sysdeps/aarch64/fpu/bits/math-vector.h index 51915cef22..52aad95e3b 100644 --- a/sysdeps/aarch64/fpu/bits/math-vector.h +++ b/sysdeps/aarch64/fpu/bits/math-vector.h @@ -57,6 +57,7 @@ __vpcs __f32x4_t _ZGVnN4v_cosf (__f32x4_t); __vpcs __f32x4_t _ZGVnN4v_expf (__f32x4_t); __vpcs __f32x4_t _ZGVnN4v_exp10f (__f32x4_t); __vpcs __f32x4_t _ZGVnN4v_exp2f (__f32x4_t); +__vpcs __f32x4_t _ZGVnN4v_expm1f (__f32x4_t); __vpcs __f32x4_t _ZGVnN4v_logf (__f32x4_t); __vpcs __f32x4_t _ZGVnN4v_log10f (__f32x4_t); __vpcs __f32x4_t _ZGVnN4v_log1pf (__f32x4_t); @@ -72,6 +73,7 @@ __vpcs __f64x2_t _ZGVnN2v_cos (__f64x2_t); __vpcs __f64x2_t _ZGVnN2v_exp (__f64x2_t); __vpcs __f64x2_t _ZGVnN2v_exp10 (__f64x2_t); __vpcs __f64x2_t _ZGVnN2v_exp2 (__f64x2_t); +__vpcs __f64x2_t _ZGVnN2v_expm1 (__f64x2_t); __vpcs __f64x2_t _ZGVnN2v_log (__f64x2_t); __vpcs __f64x2_t _ZGVnN2v_log10 (__f64x2_t); __vpcs __f64x2_t _ZGVnN2v_log1p (__f64x2_t); @@ -92,6 +94,7 @@ __sv_f32_t _ZGVsMxv_cosf (__sv_f32_t, __sv_bool_t); __sv_f32_t _ZGVsMxv_expf (__sv_f32_t, __sv_bool_t); __sv_f32_t _ZGVsMxv_exp10f (__sv_f32_t, __sv_bool_t); __sv_f32_t _ZGVsMxv_exp2f (__sv_f32_t, __sv_bool_t); +__sv_f32_t _ZGVsMxv_expm1f (__sv_f32_t, __sv_bool_t); __sv_f32_t _ZGVsMxv_logf (__sv_f32_t, __sv_bool_t); __sv_f32_t _ZGVsMxv_log10f (__sv_f32_t, __sv_bool_t); __sv_f32_t _ZGVsMxv_log1pf (__sv_f32_t, __sv_bool_t); @@ -107,6 +110,7 @@ __sv_f64_t _ZGVsMxv_cos (__sv_f64_t, __sv_bool_t); __sv_f64_t _ZGVsMxv_exp (__sv_f64_t, __sv_bool_t); __sv_f64_t _ZGVsMxv_exp10 (__sv_f64_t, __sv_bool_t); __sv_f64_t _ZGVsMxv_exp2 (__sv_f64_t, __sv_bool_t); +__sv_f64_t _ZGVsMxv_expm1 (__sv_f64_t, __sv_bool_t); __sv_f64_t _ZGVsMxv_log (__sv_f64_t, __sv_bool_t); __sv_f64_t _ZGVsMxv_log10 (__sv_f64_t, __sv_bool_t); __sv_f64_t _ZGVsMxv_log1p (__sv_f64_t, __sv_bool_t); diff --git a/sysdeps/aarch64/fpu/expm1_advsimd.c b/sysdeps/aarch64/fpu/expm1_advsimd.c new file mode 100644 index 0000000000..a3aed8e35b --- /dev/null +++ b/sysdeps/aarch64/fpu/expm1_advsimd.c @@ -0,0 +1,122 @@ +/* Double-precision AdvSIMD expm1 + + Copyright (C) 2023 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 + . */ + +#include "v_math.h" +#include "poly_advsimd_f64.h" + +static const struct data +{ + float64x2_t poly[11]; + float64x2_t invln2, ln2_lo, ln2_hi, shift; + int64x2_t exponent_bias; +#if WANT_SIMD_EXCEPT + uint64x2_t thresh, tiny_bound; +#else + float64x2_t oflow_bound; +#endif +} data = { + /* Generated using fpminimax, with degree=12 in [log(2)/2, log(2)/2]. */ + .poly = { V2 (0x1p-1), V2 (0x1.5555555555559p-3), V2 (0x1.555555555554bp-5), + V2 (0x1.111111110f663p-7), V2 (0x1.6c16c16c1b5f3p-10), + V2 (0x1.a01a01affa35dp-13), V2 (0x1.a01a018b4ecbbp-16), + V2 (0x1.71ddf82db5bb4p-19), V2 (0x1.27e517fc0d54bp-22), + V2 (0x1.af5eedae67435p-26), V2 (0x1.1f143d060a28ap-29) }, + .invln2 = V2 (0x1.71547652b82fep0), + .ln2_hi = V2 (0x1.62e42fefa39efp-1), + .ln2_lo = V2 (0x1.abc9e3b39803fp-56), + .shift = V2 (0x1.8p52), + .exponent_bias = V2 (0x3ff0000000000000), +#if WANT_SIMD_EXCEPT + /* asuint64(oflow_bound) - asuint64(0x1p-51), shifted left by 1 for abs + compare. */ + .thresh = V2 (0x78c56fa6d34b552), + /* asuint64(0x1p-51) << 1. */ + .tiny_bound = V2 (0x3cc0000000000000 << 1), +#else + /* Value above which expm1(x) should overflow. Absolute value of the + underflow bound is greater than this, so it catches both cases - there is + a small window where fallbacks are triggered unnecessarily. */ + .oflow_bound = V2 (0x1.62b7d369a5aa9p+9), +#endif +}; + +static float64x2_t VPCS_ATTR NOINLINE +special_case (float64x2_t x, float64x2_t y, uint64x2_t special) +{ + return v_call_f64 (expm1, x, y, special); +} + +/* Double-precision vector exp(x) - 1 function. + The maximum error observed error is 2.18 ULP: + _ZGVnN2v_expm1 (0x1.634ba0c237d7bp-2) got 0x1.a8b9ea8d66e22p-2 + want 0x1.a8b9ea8d66e2p-2. */ +float64x2_t VPCS_ATTR V_NAME_D1 (expm1) (float64x2_t x) +{ + const struct data *d = ptr_barrier (&data); + + uint64x2_t ix = vreinterpretq_u64_f64 (x); + +#if WANT_SIMD_EXCEPT + /* If fp exceptions are to be triggered correctly, fall back to scalar for + |x| < 2^-51, |x| > oflow_bound, Inf & NaN. Add ix to itself for + shift-left by 1, and compare with thresh which was left-shifted offline - + this is effectively an absolute compare. */ + uint64x2_t special + = vcgeq_u64 (vsubq_u64 (vaddq_u64 (ix, ix), d->tiny_bound), d->thresh); + if (__glibc_unlikely (v_any_u64 (special))) + x = v_zerofy_f64 (x, special); +#else + /* Large input, NaNs and Infs. */ + uint64x2_t special = vceqzq_u64 (vcaltq_f64 (x, d->oflow_bound)); +#endif + + /* Reduce argument to smaller range: + Let i = round(x / ln2) + and f = x - i * ln2, then f is in [-ln2/2, ln2/2]. + exp(x) - 1 = 2^i * (expm1(f) + 1) - 1 + where 2^i is exact because i is an integer. */ + float64x2_t n = vsubq_f64 (vfmaq_f64 (d->shift, d->invln2, x), d->shift); + int64x2_t i = vcvtq_s64_f64 (n); + float64x2_t f = vfmsq_f64 (x, n, d->ln2_hi); + f = vfmsq_f64 (f, n, d->ln2_lo); + + /* Approximate expm1(f) using polynomial. + Taylor expansion for expm1(x) has the form: + x + ax^2 + bx^3 + cx^4 .... + So we calculate the polynomial P(f) = a + bf + cf^2 + ... + and assemble the approximation expm1(f) ~= f + f^2 * P(f). */ + float64x2_t f2 = vmulq_f64 (f, f); + float64x2_t f4 = vmulq_f64 (f2, f2); + float64x2_t f8 = vmulq_f64 (f4, f4); + float64x2_t p = vfmaq_f64 (f, f2, v_estrin_10_f64 (f, f2, f4, f8, d->poly)); + + /* Assemble the result. + expm1(x) ~= 2^i * (p + 1) - 1 + Let t = 2^i. */ + int64x2_t u = vaddq_s64 (vshlq_n_s64 (i, 52), d->exponent_bias); + float64x2_t t = vreinterpretq_f64_s64 (u); + + if (__glibc_unlikely (v_any_u64 (special))) + return special_case (vreinterpretq_f64_u64 (ix), + vfmaq_f64 (vsubq_f64 (t, v_f64 (1.0)), p, t), + special); + + /* expm1(x) ~= p * t + (t - 1). */ + return vfmaq_f64 (vsubq_f64 (t, v_f64 (1.0)), p, t); +} diff --git a/sysdeps/aarch64/fpu/expm1_sve.c b/sysdeps/aarch64/fpu/expm1_sve.c new file mode 100644 index 0000000000..50646aff7c --- /dev/null +++ b/sysdeps/aarch64/fpu/expm1_sve.c @@ -0,0 +1,99 @@ +/* Double-precision SVE expm1 + + Copyright (C) 2023 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 + . */ + +#include "sv_math.h" +#include "poly_sve_f64.h" + +#define SpecialBound 0x1.62b7d369a5aa9p+9 +#define ExponentBias 0x3ff0000000000000 + +static const struct data +{ + double poly[11]; + double shift, inv_ln2, special_bound; + /* To be loaded in one quad-word. */ + double ln2_hi, ln2_lo; +} data = { + /* Generated using fpminimax. */ + .poly = { 0x1p-1, 0x1.5555555555559p-3, 0x1.555555555554bp-5, + 0x1.111111110f663p-7, 0x1.6c16c16c1b5f3p-10, 0x1.a01a01affa35dp-13, + 0x1.a01a018b4ecbbp-16, 0x1.71ddf82db5bb4p-19, 0x1.27e517fc0d54bp-22, + 0x1.af5eedae67435p-26, 0x1.1f143d060a28ap-29, }, + + .special_bound = SpecialBound, + .inv_ln2 = 0x1.71547652b82fep0, + .ln2_hi = 0x1.62e42fefa39efp-1, + .ln2_lo = 0x1.abc9e3b39803fp-56, + .shift = 0x1.8p52, +}; + +static svfloat64_t NOINLINE +special_case (svfloat64_t x, svfloat64_t y, svbool_t pg) +{ + return sv_call_f64 (expm1, x, y, pg); +} + +/* Double-precision vector exp(x) - 1 function. + The maximum error observed error is 2.18 ULP: + _ZGVsMxv_expm1(0x1.634ba0c237d7bp-2) got 0x1.a8b9ea8d66e22p-2 + want 0x1.a8b9ea8d66e2p-2. */ +svfloat64_t SV_NAME_D1 (expm1) (svfloat64_t x, svbool_t pg) +{ + const struct data *d = ptr_barrier (&data); + + /* Large, Nan/Inf. */ + svbool_t special = svnot_z (pg, svaclt (pg, x, d->special_bound)); + + /* Reduce argument to smaller range: + Let i = round(x / ln2) + and f = x - i * ln2, then f is in [-ln2/2, ln2/2]. + exp(x) - 1 = 2^i * (expm1(f) + 1) - 1 + where 2^i is exact because i is an integer. */ + svfloat64_t shift = sv_f64 (d->shift); + svfloat64_t n = svsub_x (pg, svmla_x (pg, shift, x, d->inv_ln2), shift); + svint64_t i = svcvt_s64_x (pg, n); + svfloat64_t ln2 = svld1rq (svptrue_b64 (), &d->ln2_hi); + svfloat64_t f = svmls_lane (x, n, ln2, 0); + f = svmls_lane (f, n, ln2, 1); + + /* Approximate expm1(f) using polynomial. + Taylor expansion for expm1(x) has the form: + x + ax^2 + bx^3 + cx^4 .... + So we calculate the polynomial P(f) = a + bf + cf^2 + ... + and assemble the approximation expm1(f) ~= f + f^2 * P(f). */ + svfloat64_t f2 = svmul_x (pg, f, f); + svfloat64_t f4 = svmul_x (pg, f2, f2); + svfloat64_t f8 = svmul_x (pg, f4, f4); + svfloat64_t p + = svmla_x (pg, f, f2, sv_estrin_10_f64_x (pg, f, f2, f4, f8, d->poly)); + + /* Assemble the result. + expm1(x) ~= 2^i * (p + 1) - 1 + Let t = 2^i. */ + svint64_t u = svadd_x (pg, svlsl_x (pg, i, 52), ExponentBias); + svfloat64_t t = svreinterpret_f64 (u); + + /* expm1(x) ~= p * t + (t - 1). */ + svfloat64_t y = svmla_x (pg, svsub_x (pg, t, 1), p, t); + + if (__glibc_unlikely (svptest_any (pg, special))) + return special_case (x, y, special); + + return y; +} diff --git a/sysdeps/aarch64/fpu/expm1f_advsimd.c b/sysdeps/aarch64/fpu/expm1f_advsimd.c new file mode 100644 index 0000000000..b27b75068a --- /dev/null +++ b/sysdeps/aarch64/fpu/expm1f_advsimd.c @@ -0,0 +1,117 @@ +/* Single-precision AdvSIMD expm1 + + Copyright (C) 2023 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 + . */ + +#include "v_math.h" +#include "poly_advsimd_f32.h" + +static const struct data +{ + float32x4_t poly[5]; + float32x4_t invln2, ln2_lo, ln2_hi, shift; + int32x4_t exponent_bias; +#if WANT_SIMD_EXCEPT + uint32x4_t thresh; +#else + float32x4_t oflow_bound; +#endif +} data = { + /* Generated using fpminimax with degree=5 in [-log(2)/2, log(2)/2]. */ + .poly = { V4 (0x1.fffffep-2), V4 (0x1.5554aep-3), V4 (0x1.555736p-5), + V4 (0x1.12287cp-7), V4 (0x1.6b55a2p-10) }, + .invln2 = V4 (0x1.715476p+0f), + .ln2_hi = V4 (0x1.62e4p-1f), + .ln2_lo = V4 (0x1.7f7d1cp-20f), + .shift = V4 (0x1.8p23f), + .exponent_bias = V4 (0x3f800000), +#if !WANT_SIMD_EXCEPT + /* Value above which expm1f(x) should overflow. Absolute value of the + underflow bound is greater than this, so it catches both cases - there is + a small window where fallbacks are triggered unnecessarily. */ + .oflow_bound = V4 (0x1.5ebc4p+6), +#else + /* asuint(oflow_bound) - asuint(0x1p-23), shifted left by 1 for absolute + compare. */ + .thresh = V4 (0x1d5ebc40), +#endif +}; + +/* asuint(0x1p-23), shifted by 1 for abs compare. */ +#define TinyBound v_u32 (0x34000000 << 1) + +static float32x4_t VPCS_ATTR NOINLINE +special_case (float32x4_t x, float32x4_t y, uint32x4_t special) +{ + return v_call_f32 (expm1f, x, y, special); +} + +/* Single-precision vector exp(x) - 1 function. + The maximum error is 1.51 ULP: + _ZGVnN4v_expm1f (0x1.8baa96p-2) got 0x1.e2fb9p-2 + want 0x1.e2fb94p-2. */ +float32x4_t VPCS_ATTR V_NAME_F1 (expm1) (float32x4_t x) +{ + const struct data *d = ptr_barrier (&data); + uint32x4_t ix = vreinterpretq_u32_f32 (x); + +#if WANT_SIMD_EXCEPT + /* If fp exceptions are to be triggered correctly, fall back to scalar for + |x| < 2^-23, |x| > oflow_bound, Inf & NaN. Add ix to itself for + shift-left by 1, and compare with thresh which was left-shifted offline - + this is effectively an absolute compare. */ + uint32x4_t special + = vcgeq_u32 (vsubq_u32 (vaddq_u32 (ix, ix), TinyBound), d->thresh); + if (__glibc_unlikely (v_any_u32 (special))) + x = v_zerofy_f32 (x, special); +#else + /* Handles very large values (+ve and -ve), +/-NaN, +/-Inf. */ + uint32x4_t special = vceqzq_u32 (vcaltq_f32 (x, d->oflow_bound)); +#endif + + /* Reduce argument to smaller range: + Let i = round(x / ln2) + and f = x - i * ln2, then f is in [-ln2/2, ln2/2]. + exp(x) - 1 = 2^i * (expm1(f) + 1) - 1 + where 2^i is exact because i is an integer. */ + float32x4_t j = vsubq_f32 (vfmaq_f32 (d->shift, d->invln2, x), d->shift); + int32x4_t i = vcvtq_s32_f32 (j); + float32x4_t f = vfmsq_f32 (x, j, d->ln2_hi); + f = vfmsq_f32 (f, j, d->ln2_lo); + + /* Approximate expm1(f) using polynomial. + Taylor expansion for expm1(x) has the form: + x + ax^2 + bx^3 + cx^4 .... + So we calculate the polynomial P(f) = a + bf + cf^2 + ... + and assemble the approximation expm1(f) ~= f + f^2 * P(f). */ + float32x4_t p = v_horner_4_f32 (f, d->poly); + p = vfmaq_f32 (f, vmulq_f32 (f, f), p); + + /* Assemble the result. + expm1(x) ~= 2^i * (p + 1) - 1 + Let t = 2^i. */ + int32x4_t u = vaddq_s32 (vshlq_n_s32 (i, 23), d->exponent_bias); + float32x4_t t = vreinterpretq_f32_s32 (u); + + if (__glibc_unlikely (v_any_u32 (special))) + return special_case (vreinterpretq_f32_u32 (ix), + vfmaq_f32 (vsubq_f32 (t, v_f32 (1.0f)), p, t), + special); + + /* expm1(x) ~= p * t + (t - 1). */ + return vfmaq_f32 (vsubq_f32 (t, v_f32 (1.0f)), p, t); +} diff --git a/sysdeps/aarch64/fpu/expm1f_sve.c b/sysdeps/aarch64/fpu/expm1f_sve.c new file mode 100644 index 0000000000..96e579e5b7 --- /dev/null +++ b/sysdeps/aarch64/fpu/expm1f_sve.c @@ -0,0 +1,99 @@ +/* Single-precision SVE expm1 + + Copyright (C) 2023 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 + . */ + +#include "sv_math.h" +#include "poly_sve_f32.h" + +/* Largest value of x for which expm1(x) should round to -1. */ +#define SpecialBound 0x1.5ebc4p+6f + +static const struct data +{ + /* These 4 are grouped together so they can be loaded as one quadword, then + used with _lane forms of svmla/svmls. */ + float c2, c4, ln2_hi, ln2_lo; + float c0, c1, c3, inv_ln2, special_bound, shift; +} data = { + /* Generated using fpminimax. */ + .c0 = 0x1.fffffep-2, .c1 = 0x1.5554aep-3, + .c2 = 0x1.555736p-5, .c3 = 0x1.12287cp-7, + .c4 = 0x1.6b55a2p-10, + + .special_bound = SpecialBound, .shift = 0x1.8p23f, + .inv_ln2 = 0x1.715476p+0f, .ln2_hi = 0x1.62e4p-1f, + .ln2_lo = 0x1.7f7d1cp-20f, +}; + +#define C(i) sv_f32 (d->c##i) + +static svfloat32_t NOINLINE +special_case (svfloat32_t x, svbool_t pg) +{ + return sv_call_f32 (expm1f, x, x, pg); +} + +/* Single-precision SVE exp(x) - 1. Maximum error is 1.52 ULP: + _ZGVsMxv_expm1f(0x1.8f4ebcp-2) got 0x1.e859dp-2 + want 0x1.e859d4p-2. */ +svfloat32_t SV_NAME_F1 (expm1) (svfloat32_t x, svbool_t pg) +{ + const struct data *d = ptr_barrier (&data); + + /* Large, NaN/Inf. */ + svbool_t special = svnot_z (pg, svaclt (pg, x, d->special_bound)); + + if (__glibc_unlikely (svptest_any (pg, special))) + return special_case (x, pg); + + /* This vector is reliant on layout of data - it contains constants + that can be used with _lane forms of svmla/svmls. Values are: + [ coeff_2, coeff_4, ln2_hi, ln2_lo ]. */ + svfloat32_t lane_constants = svld1rq (svptrue_b32 (), &d->c2); + + /* Reduce argument to smaller range: + Let i = round(x / ln2) + and f = x - i * ln2, then f is in [-ln2/2, ln2/2]. + exp(x) - 1 = 2^i * (expm1(f) + 1) - 1 + where 2^i is exact because i is an integer. */ + svfloat32_t j = svmla_x (pg, sv_f32 (d->shift), x, d->inv_ln2); + j = svsub_x (pg, j, d->shift); + svint32_t i = svcvt_s32_x (pg, j); + + svfloat32_t f = svmls_lane (x, j, lane_constants, 2); + f = svmls_lane (f, j, lane_constants, 3); + + /* Approximate expm1(f) using polynomial. + Taylor expansion for expm1(x) has the form: + x + ax^2 + bx^3 + cx^4 .... + So we calculate the polynomial P(f) = a + bf + cf^2 + ... + and assemble the approximation expm1(f) ~= f + f^2 * P(f). */ + svfloat32_t p12 = svmla_lane (C (1), f, lane_constants, 0); + svfloat32_t p34 = svmla_lane (C (3), f, lane_constants, 1); + svfloat32_t f2 = svmul_x (pg, f, f); + svfloat32_t p = svmla_x (pg, p12, f2, p34); + p = svmla_x (pg, C (0), f, p); + p = svmla_x (pg, f, f2, p); + + /* Assemble the result. + expm1(x) ~= 2^i * (p + 1) - 1 + Let t = 2^i. */ + svfloat32_t t = svreinterpret_f32 ( + svadd_x (pg, svreinterpret_u32 (svlsl_x (pg, i, 23)), 0x3f800000)); + return svmla_x (pg, svsub_x (pg, t, 1), p, t); +} diff --git a/sysdeps/aarch64/fpu/test-double-advsimd-wrappers.c b/sysdeps/aarch64/fpu/test-double-advsimd-wrappers.c index fc9e7aec47..bf495450d7 100644 --- a/sysdeps/aarch64/fpu/test-double-advsimd-wrappers.c +++ b/sysdeps/aarch64/fpu/test-double-advsimd-wrappers.c @@ -31,6 +31,7 @@ VPCS_VECTOR_WRAPPER (cos_advsimd, _ZGVnN2v_cos) VPCS_VECTOR_WRAPPER (exp_advsimd, _ZGVnN2v_exp) VPCS_VECTOR_WRAPPER (exp10_advsimd, _ZGVnN2v_exp10) VPCS_VECTOR_WRAPPER (exp2_advsimd, _ZGVnN2v_exp2) +VPCS_VECTOR_WRAPPER (expm1_advsimd, _ZGVnN2v_expm1) VPCS_VECTOR_WRAPPER (log_advsimd, _ZGVnN2v_log) VPCS_VECTOR_WRAPPER (log10_advsimd, _ZGVnN2v_log10) VPCS_VECTOR_WRAPPER (log1p_advsimd, _ZGVnN2v_log1p) diff --git a/sysdeps/aarch64/fpu/test-double-sve-wrappers.c b/sysdeps/aarch64/fpu/test-double-sve-wrappers.c index aea589d5fb..b5a627ad47 100644 --- a/sysdeps/aarch64/fpu/test-double-sve-wrappers.c +++ b/sysdeps/aarch64/fpu/test-double-sve-wrappers.c @@ -50,6 +50,7 @@ SVE_VECTOR_WRAPPER (cos_sve, _ZGVsMxv_cos) SVE_VECTOR_WRAPPER (exp_sve, _ZGVsMxv_exp) SVE_VECTOR_WRAPPER (exp10_sve, _ZGVsMxv_exp10) SVE_VECTOR_WRAPPER (exp2_sve, _ZGVsMxv_exp2) +SVE_VECTOR_WRAPPER (expm1_sve, _ZGVsMxv_expm1) SVE_VECTOR_WRAPPER (log_sve, _ZGVsMxv_log) SVE_VECTOR_WRAPPER (log10_sve, _ZGVsMxv_log10) SVE_VECTOR_WRAPPER (log1p_sve, _ZGVsMxv_log1p) diff --git a/sysdeps/aarch64/fpu/test-float-advsimd-wrappers.c b/sysdeps/aarch64/fpu/test-float-advsimd-wrappers.c index 446fd7f538..26d9e98739 100644 --- a/sysdeps/aarch64/fpu/test-float-advsimd-wrappers.c +++ b/sysdeps/aarch64/fpu/test-float-advsimd-wrappers.c @@ -31,6 +31,7 @@ VPCS_VECTOR_WRAPPER (cosf_advsimd, _ZGVnN4v_cosf) VPCS_VECTOR_WRAPPER (expf_advsimd, _ZGVnN4v_expf) VPCS_VECTOR_WRAPPER (exp10f_advsimd, _ZGVnN4v_exp10f) VPCS_VECTOR_WRAPPER (exp2f_advsimd, _ZGVnN4v_exp2f) +VPCS_VECTOR_WRAPPER (expm1f_advsimd, _ZGVnN4v_expm1f) VPCS_VECTOR_WRAPPER (logf_advsimd, _ZGVnN4v_logf) VPCS_VECTOR_WRAPPER (log10f_advsimd, _ZGVnN4v_log10f) VPCS_VECTOR_WRAPPER (log1pf_advsimd, _ZGVnN4v_log1pf) diff --git a/sysdeps/aarch64/fpu/test-float-sve-wrappers.c b/sysdeps/aarch64/fpu/test-float-sve-wrappers.c index ac17f60856..f286ee64c9 100644 --- a/sysdeps/aarch64/fpu/test-float-sve-wrappers.c +++ b/sysdeps/aarch64/fpu/test-float-sve-wrappers.c @@ -50,6 +50,7 @@ SVE_VECTOR_WRAPPER (cosf_sve, _ZGVsMxv_cosf) SVE_VECTOR_WRAPPER (expf_sve, _ZGVsMxv_expf) SVE_VECTOR_WRAPPER (exp10f_sve, _ZGVsMxv_exp10f) SVE_VECTOR_WRAPPER (exp2f_sve, _ZGVsMxv_exp2f) +SVE_VECTOR_WRAPPER (expm1f_sve, _ZGVsMxv_expm1f) SVE_VECTOR_WRAPPER (logf_sve, _ZGVsMxv_logf) SVE_VECTOR_WRAPPER (log10f_sve, _ZGVsMxv_log10f) SVE_VECTOR_WRAPPER (log1pf_sve, _ZGVsMxv_log1pf) diff --git a/sysdeps/aarch64/libm-test-ulps b/sysdeps/aarch64/libm-test-ulps index a6b2f29a6f..1d52bf9ebf 100644 --- a/sysdeps/aarch64/libm-test-ulps +++ b/sysdeps/aarch64/libm-test-ulps @@ -1078,11 +1078,19 @@ double: 1 float: 1 ldouble: 2 +Function: "expm1_advsimd": +double: 2 +float: 1 + Function: "expm1_downward": double: 1 float: 1 ldouble: 2 +Function: "expm1_sve": +double: 2 +float: 1 + Function: "expm1_towardzero": double: 1 float: 2 diff --git a/sysdeps/unix/sysv/linux/aarch64/libmvec.abilist b/sysdeps/unix/sysv/linux/aarch64/libmvec.abilist index 0f20b5be29..2bf4ea6332 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libmvec.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libmvec.abilist @@ -19,6 +19,7 @@ GLIBC_2.39 _ZGVnN2v_asin F GLIBC_2.39 _ZGVnN2v_atan F GLIBC_2.39 _ZGVnN2v_exp10 F GLIBC_2.39 _ZGVnN2v_exp2 F +GLIBC_2.39 _ZGVnN2v_expm1 F GLIBC_2.39 _ZGVnN2v_log10 F GLIBC_2.39 _ZGVnN2v_log1p F GLIBC_2.39 _ZGVnN2v_log2 F @@ -29,6 +30,7 @@ GLIBC_2.39 _ZGVnN4v_asinf F GLIBC_2.39 _ZGVnN4v_atanf F GLIBC_2.39 _ZGVnN4v_exp10f F GLIBC_2.39 _ZGVnN4v_exp2f F +GLIBC_2.39 _ZGVnN4v_expm1f F GLIBC_2.39 _ZGVnN4v_log10f F GLIBC_2.39 _ZGVnN4v_log1pf F GLIBC_2.39 _ZGVnN4v_log2f F @@ -44,6 +46,8 @@ GLIBC_2.39 _ZGVsMxv_exp10 F GLIBC_2.39 _ZGVsMxv_exp10f F GLIBC_2.39 _ZGVsMxv_exp2 F GLIBC_2.39 _ZGVsMxv_exp2f F +GLIBC_2.39 _ZGVsMxv_expm1 F +GLIBC_2.39 _ZGVsMxv_expm1f F GLIBC_2.39 _ZGVsMxv_log10 F GLIBC_2.39 _ZGVsMxv_log10f F GLIBC_2.39 _ZGVsMxv_log1p F