|
|
8ae002 |
From fdd895c45c52241f786cf4e29ccc45c240b1acb5 Mon Sep 17 00:00:00 2001
|
|
|
8ae002 |
From: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
|
|
|
8ae002 |
Date: Mon, 27 Jun 2016 16:03:10 -0300
|
|
|
8ae002 |
Subject: [PATCH] powerpc: Add a POWER8-optimized version of expf()
|
|
|
8ae002 |
|
|
|
8ae002 |
This implementation is based on the one already used at
|
|
|
8ae002 |
sysdeps/x86_64/fpu/e_expf.S.
|
|
|
8ae002 |
|
|
|
8ae002 |
This implementation improves the performance by ~14% on average in synthetic
|
|
|
8ae002 |
benchmarks at the cost of decreasing accuracy to 1 ULP.
|
|
|
8ae002 |
|
|
|
8ae002 |
(cherry picked from commit 35da2541c382d1d4b7c9a15049a3cd1c7a6863a3)
|
|
|
8ae002 |
---
|
|
|
8ae002 |
ChangeLog | 11 +
|
|
|
8ae002 |
sysdeps/powerpc/fpu/libm-test-ulps | 2 +
|
|
|
8ae002 |
sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile | 3 +-
|
|
|
8ae002 |
.../powerpc64/fpu/multiarch/e_expf-power8.S | 26 ++
|
|
|
8ae002 |
.../powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c | 24 ++
|
|
|
8ae002 |
sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c | 31 +++
|
|
|
8ae002 |
sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S | 303 +++++++++++++++++++++
|
|
|
8ae002 |
7 files changed, 399 insertions(+), 1 deletion(-)
|
|
|
8ae002 |
create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S
|
|
|
8ae002 |
create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
|
|
|
8ae002 |
create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c
|
|
|
8ae002 |
create mode 100644 sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S
|
|
|
8ae002 |
|
|
|
8ae002 |
diff --git a/ChangeLog b/ChangeLog
|
|
|
8ae002 |
index af5f694..6cb2578 100644
|
|
|
8ae002 |
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
|
|
|
8ae002 |
index 0e3eac7..331763e 100644
|
|
|
8ae002 |
--- a/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
|
|
|
8ae002 |
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
|
|
|
8ae002 |
@@ -24,7 +24,8 @@ libm-sysdep_routines += s_isnan-power7 s_isnan-power6x s_isnan-power6 \
|
|
|
8ae002 |
s_modff-power5+ s_modff-ppc64 e_hypot-ppc64 \
|
|
|
8ae002 |
e_hypot-power7 e_hypotf-ppc64 e_hypotf-power7 \
|
|
|
8ae002 |
s_isnan-power8 s_isinf-power8 s_finite-power8 \
|
|
|
8ae002 |
- s_llrint-power8 s_llround-power8
|
|
|
8ae002 |
+ s_llrint-power8 s_llround-power8 \
|
|
|
8ae002 |
+ e_expf-power8 e_expf-ppc64
|
|
|
8ae002 |
|
|
|
8ae002 |
CFLAGS-s_logbf-power7.c = -mcpu=power7
|
|
|
8ae002 |
CFLAGS-s_logbl-power7.c = -mcpu=power7
|
|
|
8ae002 |
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S
|
|
|
8ae002 |
new file mode 100644
|
|
|
8ae002 |
index 0000000..02eff24
|
|
|
8ae002 |
--- /dev/null
|
|
|
8ae002 |
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-power8.S
|
|
|
8ae002 |
@@ -0,0 +1,26 @@
|
|
|
8ae002 |
+/* __ieee754_expf() POWER8 version.
|
|
|
8ae002 |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
8ae002 |
+ This file is part of the GNU C Library.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
8ae002 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
8ae002 |
+ License as published by the Free Software Foundation; either
|
|
|
8ae002 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
8ae002 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8ae002 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
8ae002 |
+ Lesser General Public License for more details.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
8ae002 |
+ License along with the GNU C Library; if not, see
|
|
|
8ae002 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#include <sysdep.h>
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#undef strong_alias
|
|
|
8ae002 |
+#define strong_alias(a, b)
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#define __ieee754_expf __ieee754_expf_power8
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#include <sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S>
|
|
|
8ae002 |
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
|
|
|
8ae002 |
new file mode 100644
|
|
|
8ae002 |
index 0000000..40f9e3a
|
|
|
8ae002 |
--- /dev/null
|
|
|
8ae002 |
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf-ppc64.c
|
|
|
8ae002 |
@@ -0,0 +1,24 @@
|
|
|
8ae002 |
+/* __ieee_expf() PowerPC64 version.
|
|
|
8ae002 |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
8ae002 |
+ This file is part of the GNU C Library.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
8ae002 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
8ae002 |
+ License as published by the Free Software Foundation; either
|
|
|
8ae002 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
8ae002 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8ae002 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
8ae002 |
+ Lesser General Public License for more details.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
8ae002 |
+ License along with the GNU C Library; if not, see
|
|
|
8ae002 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#undef strong_alias
|
|
|
8ae002 |
+#define strong_alias(a, b)
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#define __ieee754_expf __ieee754_expf_ppc64
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#include <sysdeps/ieee754/flt-32/e_expf.c>
|
|
|
8ae002 |
diff --git a/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c
|
|
|
8ae002 |
new file mode 100644
|
|
|
8ae002 |
index 0000000..1d9a8c6
|
|
|
8ae002 |
--- /dev/null
|
|
|
8ae002 |
+++ b/sysdeps/powerpc/powerpc64/fpu/multiarch/e_expf.c
|
|
|
8ae002 |
@@ -0,0 +1,31 @@
|
|
|
8ae002 |
+/* Multiple versions of ieee754_expf.
|
|
|
8ae002 |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
8ae002 |
+ This file is part of the GNU C Library.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
8ae002 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
8ae002 |
+ License as published by the Free Software Foundation; either
|
|
|
8ae002 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
8ae002 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8ae002 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
8ae002 |
+ Lesser General Public License for more details.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
8ae002 |
+ License along with the GNU C Library; if not, see
|
|
|
8ae002 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#include <math.h>
|
|
|
8ae002 |
+#include <math_ldbl_opt.h>
|
|
|
8ae002 |
+#include "init-arch.h"
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+extern __typeof (__ieee754_expf) __ieee754_expf_ppc64 attribute_hidden;
|
|
|
8ae002 |
+extern __typeof (__ieee754_expf) __ieee754_expf_power8 attribute_hidden;
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+libc_ifunc (__ieee754_expf,
|
|
|
8ae002 |
+ (hwcap2 & PPC_FEATURE2_ARCH_2_07)
|
|
|
8ae002 |
+ ? __ieee754_expf_power8
|
|
|
8ae002 |
+ : __ieee754_expf_ppc64);
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+strong_alias (__ieee754_expf, __expf_finite)
|
|
|
8ae002 |
diff --git a/sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S b/sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S
|
|
|
8ae002 |
new file mode 100644
|
|
|
8ae002 |
index 0000000..a5e68bb
|
|
|
8ae002 |
--- /dev/null
|
|
|
8ae002 |
+++ b/sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S
|
|
|
8ae002 |
@@ -0,0 +1,303 @@
|
|
|
8ae002 |
+/* Optimized expf(). PowerPC64/POWER8 version.
|
|
|
8ae002 |
+ Copyright (C) 2016 Free Software Foundation, Inc.
|
|
|
8ae002 |
+ This file is part of the GNU C Library.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
8ae002 |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
8ae002 |
+ License as published by the Free Software Foundation; either
|
|
|
8ae002 |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
8ae002 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
8ae002 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
8ae002 |
+ Lesser General Public License for more details.
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
8ae002 |
+ License along with the GNU C Library; if not, see
|
|
|
8ae002 |
+ <http://www.gnu.org/licenses/>. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#include <sysdep.h>
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+/* Short algorithm description:
|
|
|
8ae002 |
+ *
|
|
|
8ae002 |
+ * Let K = 64 (table size).
|
|
|
8ae002 |
+ * e^x = 2^(x/log(2)) = 2^n * T[j] * (1 + P(y))
|
|
|
8ae002 |
+ * where:
|
|
|
8ae002 |
+ * x = m*log(2)/K + y, y in [0.0..log(2)/K]
|
|
|
8ae002 |
+ * m = n*K + j, m,n,j - signed integer, j in [0..K-1]
|
|
|
8ae002 |
+ * values of 2^(j/K) are tabulated as T[j].
|
|
|
8ae002 |
+ *
|
|
|
8ae002 |
+ * P(y) is a minimax polynomial approximation of expf(y)-1
|
|
|
8ae002 |
+ * on small interval [0.0..log(2)/K].
|
|
|
8ae002 |
+ *
|
|
|
8ae002 |
+ * P(y) = P3*y*y*y*y + P2*y*y*y + P1*y*y + P0*y, calculated as
|
|
|
8ae002 |
+ * z = y*y; P(y) = (P3*z + P1)*z + (P2*z + P0)*y
|
|
|
8ae002 |
+ *
|
|
|
8ae002 |
+ * Special cases:
|
|
|
8ae002 |
+ * expf(NaN) = NaN
|
|
|
8ae002 |
+ * expf(+INF) = +INF
|
|
|
8ae002 |
+ * expf(-INF) = 0
|
|
|
8ae002 |
+ * expf(x) = 1 for subnormals
|
|
|
8ae002 |
+ * for finite argument, only expf(0)=1 is exact
|
|
|
8ae002 |
+ * expf(x) overflows if x>88.7228317260742190
|
|
|
8ae002 |
+ * expf(x) underflows if x<-103.972076416015620
|
|
|
8ae002 |
+ */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#define C1 0x42ad496b /* Single precision 125*log(2). */
|
|
|
8ae002 |
+#define C2 0x31800000 /* Single precision 2^(-28). */
|
|
|
8ae002 |
+#define SP_INF 0x7f800000 /* Single precision Inf. */
|
|
|
8ae002 |
+#define SP_EXP_BIAS 0x1fc0 /* Single precision exponent bias. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+#define DATA_OFFSET r9
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+/* Implements the function
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ float [fp1] expf (float [fp1] x) */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ .machine power8
|
|
|
8ae002 |
+EALIGN(__ieee754_expf, 4, 0)
|
|
|
8ae002 |
+ addis DATA_OFFSET,r2,.Lanchor@toc@ha
|
|
|
8ae002 |
+ addi DATA_OFFSET,DATA_OFFSET,.Lanchor@toc@l
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ xscvdpspn v0,v1
|
|
|
8ae002 |
+ mfvsrd r8,v0 /* r8 = x */
|
|
|
8ae002 |
+ lfd fp2,(.KLN2-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ lfd fp3,(.P2-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ rldicl r3,r8,32,33 /* r3 = |x| */
|
|
|
8ae002 |
+ lis r4,C1@ha /* r4 = 125*log(2) */
|
|
|
8ae002 |
+ ori r4,r4,C1@l
|
|
|
8ae002 |
+ cmpw r3,r4
|
|
|
8ae002 |
+ lfd fp5,(.P3-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ lfd fp4,(.RS-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ fmadd fp2,fp1,fp2,fp4 /* fp2 = x * K/log(2) + (2^23 + 2^22) */
|
|
|
8ae002 |
+ bge L(special_paths) /* |x| >= 125*log(2) ? */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ lis r4,C2@ha
|
|
|
8ae002 |
+ ori r4,r4,C2@l
|
|
|
8ae002 |
+ cmpw r3,r4
|
|
|
8ae002 |
+ blt L(small_args) /* |x| < 2^(-28) ? */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ /* Main path: here if 2^(-28) <= |x| < 125*log(2) */
|
|
|
8ae002 |
+ frsp fp6,fp2
|
|
|
8ae002 |
+ xscvdpsp v2,v2
|
|
|
8ae002 |
+ mfvsrd r8,v2
|
|
|
8ae002 |
+ mr r3,r8 /* r3 = m */
|
|
|
8ae002 |
+ rldicl r8,r8,32,58 /* r8 = j */
|
|
|
8ae002 |
+ lfs fp4,(.SP_RS-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ fsubs fp2,fp6,fp4 /* fp2 = m = x * K/log(2) */
|
|
|
8ae002 |
+ srdi r3,r3,32
|
|
|
8ae002 |
+ clrrwi r3,r3,6 /* r3 = n */
|
|
|
8ae002 |
+ lfd fp6,(.NLN2K-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ fmadd fp0,fp2,fp6,fp1 /* fp0 = y = x - m*log(2)/K */
|
|
|
8ae002 |
+ fmul fp2,fp0,fp0 /* fp2 = z = y^2 */
|
|
|
8ae002 |
+ lfd fp4,(.P1-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ lfd fp6,(.P0-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ lis r4,SP_EXP_BIAS@ha
|
|
|
8ae002 |
+ ori r4,r4,SP_EXP_BIAS@l
|
|
|
8ae002 |
+ add r3,r3,r4
|
|
|
8ae002 |
+ rldic r3,r3,49,1 /* r3 = 2^n */
|
|
|
8ae002 |
+ fmadd fp4,fp5,fp2,fp4 /* fp4 = P3 * z + P1 */
|
|
|
8ae002 |
+ fmadd fp6,fp3,fp2,fp6 /* fp6 = P2 * z + P0 */
|
|
|
8ae002 |
+ mtvsrd v1,r3
|
|
|
8ae002 |
+ xscvspdp v1,v1
|
|
|
8ae002 |
+ fmul fp4,fp4,fp2 /* fp4 = (P3 * z + P1)*z */
|
|
|
8ae002 |
+ fmadd fp0,fp0,fp6,fp4 /* fp0 = P(y) */
|
|
|
8ae002 |
+ sldi r8,r8,3 /* Access doublewords from T[j]. */
|
|
|
8ae002 |
+ addi r6,DATA_OFFSET,(.Ttable-.Lanchor)
|
|
|
8ae002 |
+ lfdx fp3,r6,r8
|
|
|
8ae002 |
+ fmadd fp0,fp0,fp3,fp3 /* fp0 = T[j] * (1 + P(y)) */
|
|
|
8ae002 |
+ fmul fp1,fp1,fp0 /* fp1 = 2^n * T[j] * (1 + P(y)) */
|
|
|
8ae002 |
+ frsp fp1,fp1
|
|
|
8ae002 |
+ blr
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ .align 4
|
|
|
8ae002 |
+/* x is either underflow, overflow, infinite or NaN. */
|
|
|
8ae002 |
+L(special_paths):
|
|
|
8ae002 |
+ srdi r8,r8,32
|
|
|
8ae002 |
+ rlwinm r8,r8,3,29,29 /* r8 = 0, if x positive.
|
|
|
8ae002 |
+ r8 = 4, otherwise. */
|
|
|
8ae002 |
+ addi r6,DATA_OFFSET,(.SPRANGE-.Lanchor)
|
|
|
8ae002 |
+ lwzx r4,r6,r8 /* r4 = .SPRANGE[signbit(x)] */
|
|
|
8ae002 |
+ cmpw r3,r4
|
|
|
8ae002 |
+ /* |x| <= .SPRANGE[signbit(x)] */
|
|
|
8ae002 |
+ ble L(near_under_or_overflow)
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ lis r4,SP_INF@ha
|
|
|
8ae002 |
+ ori r4,r4,SP_INF@l
|
|
|
8ae002 |
+ cmpw r3,r4
|
|
|
8ae002 |
+ bge L(arg_inf_or_nan) /* |x| > Infinite ? */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ addi r6,DATA_OFFSET,(.SPLARGE_SMALL-.Lanchor)
|
|
|
8ae002 |
+ lfsx fp1,r6,r8
|
|
|
8ae002 |
+ fmuls fp1,fp1,fp1
|
|
|
8ae002 |
+ blr
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ .align 4
|
|
|
8ae002 |
+L(small_args):
|
|
|
8ae002 |
+ /* expf(x) = 1.0, where |x| < |2^(-28)| */
|
|
|
8ae002 |
+ lfs fp2,(.SPone-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ fadds fp1,fp1,fp2
|
|
|
8ae002 |
+ blr
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ .align 4
|
|
|
8ae002 |
+L(arg_inf_or_nan:)
|
|
|
8ae002 |
+ bne L(arg_nan)
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ /* expf(+INF) = +INF
|
|
|
8ae002 |
+ expf(-INF) = 0 */
|
|
|
8ae002 |
+ addi r6,DATA_OFFSET,(.INF_ZERO-.Lanchor)
|
|
|
8ae002 |
+ lfsx fp1,r6,r8
|
|
|
8ae002 |
+ blr
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ .align 4
|
|
|
8ae002 |
+L(arg_nan):
|
|
|
8ae002 |
+ /* expf(NaN) = NaN */
|
|
|
8ae002 |
+ fadd fp1,fp1,fp1
|
|
|
8ae002 |
+ frsp fp1,fp1
|
|
|
8ae002 |
+ blr
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ .align 4
|
|
|
8ae002 |
+L(near_under_or_overflow):
|
|
|
8ae002 |
+ frsp fp6,fp2
|
|
|
8ae002 |
+ xscvdpsp v2,v2
|
|
|
8ae002 |
+ mfvsrd r8,v2
|
|
|
8ae002 |
+ mr r3,r8 /* r3 = m */
|
|
|
8ae002 |
+ rldicl r8,r8,32,58 /* r8 = j */
|
|
|
8ae002 |
+ lfs fp4,(.SP_RS-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ fsubs fp2,fp6,fp4 /* fp2 = m = x * K/log(2) */
|
|
|
8ae002 |
+ srdi r3,r3,32
|
|
|
8ae002 |
+ clrrwi r3,r3,6 /* r3 = n */
|
|
|
8ae002 |
+ lfd fp6,(.NLN2K-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ fmadd fp0,fp2,fp6,fp1 /* fp0 = y = x - m*log(2)/K */
|
|
|
8ae002 |
+ fmul fp2,fp0,fp0 /* fp2 = z = y^2 */
|
|
|
8ae002 |
+ lfd fp4,(.P1-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ lfd fp6,(.P0-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ ld r4,(.DP_EXP_BIAS-.Lanchor)(DATA_OFFSET)
|
|
|
8ae002 |
+ add r3,r3,r4
|
|
|
8ae002 |
+ rldic r3,r3,46,1 /* r3 = 2 */
|
|
|
8ae002 |
+ fmadd fp4,fp5,fp2,fp4 /* fp4 = P3 * z + P1 */
|
|
|
8ae002 |
+ fmadd fp6,fp3,fp2,fp6 /* fp6 = P2 * z + P0 */
|
|
|
8ae002 |
+ mtvsrd v1,r3
|
|
|
8ae002 |
+ fmul fp4,fp4,fp2 /* fp4 = (P3*z + P1)*z */
|
|
|
8ae002 |
+ fmadd fp0,fp0,fp6,fp4 /* fp0 = P(y) */
|
|
|
8ae002 |
+ sldi r8,r8,3 /* Access doublewords from T[j]. */
|
|
|
8ae002 |
+ addi r6,DATA_OFFSET,(.Ttable-.Lanchor)
|
|
|
8ae002 |
+ lfdx fp3,r6,r8
|
|
|
8ae002 |
+ fmadd fp0,fp0,fp3,fp3 /* fp0 = T[j] * (1 + T[j]) */
|
|
|
8ae002 |
+ fmul fp1,fp1,fp0 /* fp1 = 2^n * T[j] * (1 + T[j]) */
|
|
|
8ae002 |
+ frsp fp1,fp1
|
|
|
8ae002 |
+ blr
|
|
|
8ae002 |
+END(__ieee754_expf)
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ .section .rodata, "a",@progbits
|
|
|
8ae002 |
+.Lanchor:
|
|
|
8ae002 |
+ .balign 8
|
|
|
8ae002 |
+/* Table T[j] = 2^(j/K). Double precision. */
|
|
|
8ae002 |
+.Ttable:
|
|
|
8ae002 |
+ .8byte 0x3ff0000000000000
|
|
|
8ae002 |
+ .8byte 0x3ff02c9a3e778061
|
|
|
8ae002 |
+ .8byte 0x3ff059b0d3158574
|
|
|
8ae002 |
+ .8byte 0x3ff0874518759bc8
|
|
|
8ae002 |
+ .8byte 0x3ff0b5586cf9890f
|
|
|
8ae002 |
+ .8byte 0x3ff0e3ec32d3d1a2
|
|
|
8ae002 |
+ .8byte 0x3ff11301d0125b51
|
|
|
8ae002 |
+ .8byte 0x3ff1429aaea92de0
|
|
|
8ae002 |
+ .8byte 0x3ff172b83c7d517b
|
|
|
8ae002 |
+ .8byte 0x3ff1a35beb6fcb75
|
|
|
8ae002 |
+ .8byte 0x3ff1d4873168b9aa
|
|
|
8ae002 |
+ .8byte 0x3ff2063b88628cd6
|
|
|
8ae002 |
+ .8byte 0x3ff2387a6e756238
|
|
|
8ae002 |
+ .8byte 0x3ff26b4565e27cdd
|
|
|
8ae002 |
+ .8byte 0x3ff29e9df51fdee1
|
|
|
8ae002 |
+ .8byte 0x3ff2d285a6e4030b
|
|
|
8ae002 |
+ .8byte 0x3ff306fe0a31b715
|
|
|
8ae002 |
+ .8byte 0x3ff33c08b26416ff
|
|
|
8ae002 |
+ .8byte 0x3ff371a7373aa9cb
|
|
|
8ae002 |
+ .8byte 0x3ff3a7db34e59ff7
|
|
|
8ae002 |
+ .8byte 0x3ff3dea64c123422
|
|
|
8ae002 |
+ .8byte 0x3ff4160a21f72e2a
|
|
|
8ae002 |
+ .8byte 0x3ff44e086061892d
|
|
|
8ae002 |
+ .8byte 0x3ff486a2b5c13cd0
|
|
|
8ae002 |
+ .8byte 0x3ff4bfdad5362a27
|
|
|
8ae002 |
+ .8byte 0x3ff4f9b2769d2ca7
|
|
|
8ae002 |
+ .8byte 0x3ff5342b569d4f82
|
|
|
8ae002 |
+ .8byte 0x3ff56f4736b527da
|
|
|
8ae002 |
+ .8byte 0x3ff5ab07dd485429
|
|
|
8ae002 |
+ .8byte 0x3ff5e76f15ad2148
|
|
|
8ae002 |
+ .8byte 0x3ff6247eb03a5585
|
|
|
8ae002 |
+ .8byte 0x3ff6623882552225
|
|
|
8ae002 |
+ .8byte 0x3ff6a09e667f3bcd
|
|
|
8ae002 |
+ .8byte 0x3ff6dfb23c651a2f
|
|
|
8ae002 |
+ .8byte 0x3ff71f75e8ec5f74
|
|
|
8ae002 |
+ .8byte 0x3ff75feb564267c9
|
|
|
8ae002 |
+ .8byte 0x3ff7a11473eb0187
|
|
|
8ae002 |
+ .8byte 0x3ff7e2f336cf4e62
|
|
|
8ae002 |
+ .8byte 0x3ff82589994cce13
|
|
|
8ae002 |
+ .8byte 0x3ff868d99b4492ed
|
|
|
8ae002 |
+ .8byte 0x3ff8ace5422aa0db
|
|
|
8ae002 |
+ .8byte 0x3ff8f1ae99157736
|
|
|
8ae002 |
+ .8byte 0x3ff93737b0cdc5e5
|
|
|
8ae002 |
+ .8byte 0x3ff97d829fde4e50
|
|
|
8ae002 |
+ .8byte 0x3ff9c49182a3f090
|
|
|
8ae002 |
+ .8byte 0x3ffa0c667b5de565
|
|
|
8ae002 |
+ .8byte 0x3ffa5503b23e255d
|
|
|
8ae002 |
+ .8byte 0x3ffa9e6b5579fdbf
|
|
|
8ae002 |
+ .8byte 0x3ffae89f995ad3ad
|
|
|
8ae002 |
+ .8byte 0x3ffb33a2b84f15fb
|
|
|
8ae002 |
+ .8byte 0x3ffb7f76f2fb5e47
|
|
|
8ae002 |
+ .8byte 0x3ffbcc1e904bc1d2
|
|
|
8ae002 |
+ .8byte 0x3ffc199bdd85529c
|
|
|
8ae002 |
+ .8byte 0x3ffc67f12e57d14b
|
|
|
8ae002 |
+ .8byte 0x3ffcb720dcef9069
|
|
|
8ae002 |
+ .8byte 0x3ffd072d4a07897c
|
|
|
8ae002 |
+ .8byte 0x3ffd5818dcfba487
|
|
|
8ae002 |
+ .8byte 0x3ffda9e603db3285
|
|
|
8ae002 |
+ .8byte 0x3ffdfc97337b9b5f
|
|
|
8ae002 |
+ .8byte 0x3ffe502ee78b3ff6
|
|
|
8ae002 |
+ .8byte 0x3ffea4afa2a490da
|
|
|
8ae002 |
+ .8byte 0x3ffefa1bee615a27
|
|
|
8ae002 |
+ .8byte 0x3fff50765b6e4540
|
|
|
8ae002 |
+ .8byte 0x3fffa7c1819e90d8
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+.KLN2:
|
|
|
8ae002 |
+ .8byte 0x40571547652b82fe /* Double precision K/log(2). */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+/* Double precision polynomial coefficients. */
|
|
|
8ae002 |
+.P0:
|
|
|
8ae002 |
+ .8byte 0x3fefffffffffe7c6
|
|
|
8ae002 |
+.P1:
|
|
|
8ae002 |
+ .8byte 0x3fe00000008d6118
|
|
|
8ae002 |
+.P2:
|
|
|
8ae002 |
+ .8byte 0x3fc55550da752d4f
|
|
|
8ae002 |
+.P3:
|
|
|
8ae002 |
+ .8byte 0x3fa56420eb78fa85
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+.RS:
|
|
|
8ae002 |
+ .8byte 0x4168000000000000 /* Double precision 2^23 + 2^22. */
|
|
|
8ae002 |
+.NLN2K:
|
|
|
8ae002 |
+ .8byte 0xbf862e42fefa39ef /* Double precision -log(2)/K. */
|
|
|
8ae002 |
+.DP_EXP_BIAS:
|
|
|
8ae002 |
+ .8byte 0x000000000000ffc0 /* Double precision exponent bias. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+ .balign 4
|
|
|
8ae002 |
+.SPone:
|
|
|
8ae002 |
+ .4byte 0x3f800000 /* Single precision 1.0. */
|
|
|
8ae002 |
+.SP_RS:
|
|
|
8ae002 |
+ .4byte 0x4b400000 /* Single precision 2^23 + 2^22. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+.SPRANGE: /* Single precision overflow/underflow bounds. */
|
|
|
8ae002 |
+ .4byte 0x42b17217 /* if x>this bound, then result overflows. */
|
|
|
8ae002 |
+ .4byte 0x42cff1b4 /* if x
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+.SPLARGE_SMALL:
|
|
|
8ae002 |
+ .4byte 0x71800000 /* 2^100. */
|
|
|
8ae002 |
+ .4byte 0x0d800000 /* 2^-100. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+.INF_ZERO:
|
|
|
8ae002 |
+ .4byte 0x7f800000 /* Single precision Inf. */
|
|
|
8ae002 |
+ .4byte 0 /* Single precision zero. */
|
|
|
8ae002 |
+
|
|
|
8ae002 |
+strong_alias (__ieee754_expf, __expf_finite)
|
|
|
8ae002 |
--
|
|
|
8ae002 |
2.1.0
|
|
|
8ae002 |
|