about summary refs log tree commit diff
path: root/sysdeps/x86_64/fpu
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-05-06 18:23:44 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-05-06 18:23:44 +0000
commitd8b82cad1b525bdcbfff88d218c7c45032e4a3af (patch)
tree77e88bf7642e69d74d4df3d771ffbb4274937b31 /sysdeps/x86_64/fpu
parent6c23e11c4dd036e65073d4e4d6bc971a445deaea (diff)
downloadglibc-d8b82cad1b525bdcbfff88d218c7c45032e4a3af.tar.gz
glibc-d8b82cad1b525bdcbfff88d218c7c45032e4a3af.tar.xz
glibc-d8b82cad1b525bdcbfff88d218c7c45032e4a3af.zip
Fix exp10 inaccuracy and exceptions (bugs 13884, 13914).
Diffstat (limited to 'sysdeps/x86_64/fpu')
-rw-r--r--sysdeps/x86_64/fpu/e_exp10l.S2
-rw-r--r--sysdeps/x86_64/fpu/e_expl.S37
-rw-r--r--sysdeps/x86_64/fpu/libm-test-ulps9
3 files changed, 40 insertions, 8 deletions
diff --git a/sysdeps/x86_64/fpu/e_exp10l.S b/sysdeps/x86_64/fpu/e_exp10l.S
new file mode 100644
index 0000000000..d843e2b5e8
--- /dev/null
+++ b/sysdeps/x86_64/fpu/e_exp10l.S
@@ -0,0 +1,2 @@
+#define USE_AS_EXP10L
+#include <e_expl.S>
diff --git a/sysdeps/x86_64/fpu/e_expl.S b/sysdeps/x86_64/fpu/e_expl.S
index d497b28973..fd613f91d3 100644
--- a/sysdeps/x86_64/fpu/e_expl.S
+++ b/sysdeps/x86_64/fpu/e_expl.S
@@ -24,9 +24,29 @@
 
 #include <machine/asm.h>
 
+#ifdef USE_AS_EXP10L
+# define IEEE754_EXPL __ieee754_exp10l
+# define EXPL_FINITE __exp10l_finite
+# define FLDLOG fldl2t
+#else
+# define IEEE754_EXPL __ieee754_expl
+# define EXPL_FINITE __expl_finite
+# define FLDLOG fldl2e
+#endif
+
 	.section .rodata.cst16,"aM",@progbits,16
 
 	.p2align 4
+#ifdef USE_AS_EXP10L
+	ASM_TYPE_DIRECTIVE(c0,@object)
+c0:	.byte 0, 0, 0, 0, 0, 0, 0x9a, 0xd4, 0x00, 0x40
+	.byte 0, 0, 0, 0, 0, 0
+	ASM_SIZE_DIRECTIVE(c0)
+	ASM_TYPE_DIRECTIVE(c1,@object)
+c1:	.byte 0x58, 0x92, 0xfc, 0x15, 0x37, 0x9a, 0x97, 0xf0, 0xef, 0x3f
+	.byte 0, 0, 0, 0, 0, 0
+	ASM_SIZE_DIRECTIVE(c1)
+#else
 	ASM_TYPE_DIRECTIVE(c0,@object)
 c0:	.byte 0, 0, 0, 0, 0, 0, 0xaa, 0xb8, 0xff, 0x3f
 	.byte 0, 0, 0, 0, 0, 0
@@ -35,6 +55,7 @@ c0:	.byte 0, 0, 0, 0, 0, 0, 0xaa, 0xb8, 0xff, 0x3f
 c1:	.byte 0x20, 0xfa, 0xee, 0xc2, 0x5f, 0x70, 0xa5, 0xec, 0xed, 0x3f
 	.byte 0, 0, 0, 0, 0, 0
 	ASM_SIZE_DIRECTIVE(c1)
+#endif
 	ASM_TYPE_DIRECTIVE(csat,@object)
 csat:	.byte 0, 0, 0, 0, 0, 0, 0, 0x80, 0x0e, 0x40
 	.byte 0, 0, 0, 0, 0, 0
@@ -47,7 +68,7 @@ csat:	.byte 0, 0, 0, 0, 0, 0, 0, 0x80, 0x0e, 0x40
 #endif
 
 	.text
-ENTRY(__ieee754_expl)
+ENTRY(IEEE754_EXPL)
 	fldt	8(%rsp)
 /* I added the following ugly construct because expl(+-Inf) resulted
    in NaN.  The ugliness results from the bright minds at Intel.
@@ -72,8 +93,8 @@ ENTRY(__ieee754_expl)
 	andb	$2, %ah
 	jz	3f
 	fchs
-3:	fldl2e			/* 1  log2(e)         */
-	fmul	%st(1), %st	/* 1  x log2(e)       */
+3:	FLDLOG			/* 1  log2(base)      */
+	fmul	%st(1), %st	/* 1  x log2(base)    */
 	frndint			/* 1  i               */
 	fld	%st(1)		/* 2  x               */
 	frndint			/* 2  xi              */
@@ -89,11 +110,11 @@ ENTRY(__ieee754_expl)
 	fldt	MO(c1)		/* 4                  */
 	fmul	%st(4), %st	/* 4  c1 * x          */
 	faddp	%st, %st(1)	/* 3  f = f + c1 * x  */
-	f2xm1			/* 3 2^(fract(x * log2(e))) - 1 */
+	f2xm1			/* 3 2^(fract(x * log2(base))) - 1 */
 	fld1			/* 4 1.0              */
-	faddp			/* 3 2^(fract(x * log2(e))) */
+	faddp			/* 3 2^(fract(x * log2(base))) */
 	fstp	%st(1)		/* 2  */
-	fscale			/* 2 scale factor is st(1); e^x */
+	fscale			/* 2 scale factor is st(1); base^x */
 	fstp	%st(1)		/* 1  */
 	fstp	%st(1)		/* 0  */
 	jmp	2f
@@ -102,5 +123,5 @@ ENTRY(__ieee754_expl)
 	fstp	%st
 	fldz			/* Set result to 0.  */
 2:	ret
-END(__ieee754_expl)
-strong_alias (__ieee754_expl, __expl_finite)
+END(IEEE754_EXPL)
+strong_alias (IEEE754_EXPL, EXPL_FINITE)
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 70b091f547..f33c07f326 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -1287,6 +1287,12 @@ idouble: 2
 ifloat: 1
 ildouble: 1
 ldouble: 1
+Test "exp10 (-305) == 1.0e-305":
+double: 1
+idouble: 1
+Test "exp10 (-36) == 1.0e-36":
+double: 1
+idouble: 1
 Test "exp10 (0.75) == 5.62341325190349080394951039776481231":
 double: 1
 float: 1
@@ -1301,6 +1307,9 @@ idouble: 6
 ifloat: 2
 ildouble: 8
 ldouble: 8
+Test "exp10 (36) == 1.0e36":
+double: 1
+idouble: 1
 
 # exp_downward
 Test "exp_downward (1) == e":