about summary refs log tree commit diff
path: root/sysdeps/x86_64
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-12-21 13:07:16 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-12-21 13:07:16 +0000
commit5b0626b9c50e69fe4d7dce90199d78f398c249b1 (patch)
tree670c05d54f1077faf9cc39577449e67eba964a9f /sysdeps/x86_64
parent31e3a40588f6b215f2583c12ba29ff5cea63d2ef (diff)
downloadglibc-5b0626b9c50e69fe4d7dce90199d78f398c249b1.tar.gz
glibc-5b0626b9c50e69fe4d7dce90199d78f398c249b1.tar.xz
glibc-5b0626b9c50e69fe4d7dce90199d78f398c249b1.zip
Fix x86 / x86_64 expl / expl10l wild results in directed rounding modes (bug 16356).
This patch fixes bug 16356, bad results from x86 / x86_64 expl /
exp10l in directed rounding modes, the most serious of the bugs shown
up by my patch expanding libm test coverage.  When I fixed bug 16293,
I thought it was only necessary to set round-to-nearest when using
frndint in expm1 functions, because in other cases the cancellation
error from having the resulting fractional part close to 1 or -1 would
not be significant.  However, in expl and exp10l, the way the final
fractional part gets computed (something more complicated than a
simple subtraction, because more precision is needed than you'd get
that way) can result in a value outside the range [-1, 1] when the
argument to frndint was very close to an integer and was rounded the
"wrong" way because of the rounding mode - and the f2xm1 instruction
has undefined results if its argument is outside [-1, 1], so resulting
in the large errors seen.  So this patch removes the USE_AS_EXPM1L
conditionals on the round-to-nearest settings, so all of expl, expm1l
and exp10l now get round-to-nearest used for frndint (meaning the
final fractional part can at most be slightly above 0.5 in
magnitude).  Associated tests of exp and exp10 are added and testing
of exp10 in directed rounding modes enabled.

Tested x86_64 and x86 and ulps updated accordingly.

	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL): Also set
	round-to-nearest for [!USE_AS_EXPM1L].
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL): Likewise.
	* math/auto-libm-test-in: Do not expect cosh tests to fail.  Add
	more tests of exp and exp10.  Expect some exp10 tests to miss
	exceptions or fail in directed rounding modes.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (exp10_tonearest_test_data): New array.
	(exp10_test_tonearest): New function.
	(exp10_towardzero_test_data): New array.
	(exp10_test_towardzero): New function.
	(exp10_downward_test_data): New array.
	(exp10_test_downward): New function.
	(exp10_upward_test_data): New array.
	(exp10_test_upward): New function.
	(main): Call the new functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Diffstat (limited to 'sysdeps/x86_64')
-rw-r--r--sysdeps/x86_64/fpu/e_expl.S4
-rw-r--r--sysdeps/x86_64/fpu/libm-test-ulps122
2 files changed, 118 insertions, 8 deletions
diff --git a/sysdeps/x86_64/fpu/e_expl.S b/sysdeps/x86_64/fpu/e_expl.S
index 1c21f03ddc..36d30c26d3 100644
--- a/sysdeps/x86_64/fpu/e_expl.S
+++ b/sysdeps/x86_64/fpu/e_expl.S
@@ -127,20 +127,16 @@ ENTRY(IEEE754_EXPL)
 #endif
 3:	FLDLOG			/* 1  log2(base)      */
 	fmul	%st(1), %st	/* 1  x log2(base)    */
-#ifdef USE_AS_EXPM1L
 	/* Set round-to-nearest temporarily.  */
 	fstcw	-4(%rsp)
 	movl	$0xf3ff, %edx
 	andl	-4(%rsp), %edx
 	movl	%edx, -8(%rsp)
 	fldcw	-8(%rsp)
-#endif
 	frndint			/* 1  i               */
 	fld	%st(1)		/* 2  x               */
 	frndint			/* 2  xi              */
-#ifdef USE_AS_EXPM1L
 	fldcw	-4(%rsp)
-#endif
 	fld	%st(1)		/* 3  i               */
 	fldt	MO(c0)		/* 4  c0              */
 	fld	%st(2)		/* 5  xi              */
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 6404c74303..9c3b1b769e 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -8125,6 +8125,9 @@ ldouble: 2
 Test "cosh_towardzero (0x1.7p+4)":
 double: 1
 idouble: 1
+Test "cosh_towardzero (0x1.8p+4)":
+ildouble: 1
+ldouble: 1
 Test "cosh_towardzero (0x2.c5d374p+12)":
 ldouble: 1
 Test "cosh_towardzero (0x2.c5d37700c6bb03a4p+12)":
@@ -8180,6 +8183,9 @@ idouble: 1
 Test "cosh_upward (-0x2.c679d1f73f0fap+8)":
 double: 1
 idouble: 1
+Test "cosh_upward (-0x2.c679d1f73f0fb628p+8)":
+ildouble: 1
+ldouble: 1
 Test "cosh_upward (-0x2.c679dp+8)":
 double: 1
 idouble: 1
@@ -8215,6 +8221,9 @@ idouble: 1
 Test "cosh_upward (0x2.c679d1f73f0fap+8)":
 double: 1
 idouble: 1
+Test "cosh_upward (0x2.c679d1f73f0fb628p+8)":
+ildouble: 1
+ldouble: 1
 Test "cosh_upward (0x2.c679dp+8)":
 double: 1
 idouble: 1
@@ -9312,11 +9321,13 @@ Test "Real part of: ctan_towardzero (0x1p+0 + 0x1.63p+8 i)":
 ildouble: 1
 ldouble: 1
 Test "Real part of: ctan_towardzero (0x1p+0 + 0x1.6dp+8 i)":
-ildouble: 1
-ldouble: 1
+ildouble: 2
+ldouble: 2
 Test "Real part of: ctan_towardzero (0x1p+0 + 0x2.dp+4 i)":
 double: 1
 idouble: 1
+ildouble: 1
+ldouble: 1
 Test "Real part of: ctan_towardzero (0x1p+0 + 0x2.fp+4 i)":
 ildouble: 1
 ldouble: 1
@@ -9352,6 +9363,9 @@ float: 1
 ifloat: 1
 ildouble: 1
 ldouble: 1
+Test "Imaginary part of: ctan_towardzero (0xcp-4 + 0x1.4p+0 i)":
+ildouble: 2
+ldouble: 2
 Test "Real part of: ctan_towardzero (0xf.ffffffffffff8p+1020 + 0x1p+0 i)":
 double: 2
 idouble: 2
@@ -10342,8 +10356,8 @@ Test "Imaginary part of: ctanh_towardzero (0x1.63p+8 + 0x1p+0 i)":
 ildouble: 1
 ldouble: 1
 Test "Imaginary part of: ctanh_towardzero (0x1.6dp+8 + 0x1p+0 i)":
-ildouble: 1
-ldouble: 1
+ildouble: 2
+ldouble: 2
 Test "Imaginary part of: ctanh_towardzero (0x1p+0 + 0x8p+1020 i)":
 double: 5
 idouble: 5
@@ -10396,6 +10410,8 @@ ldouble: 1
 Test "Imaginary part of: ctanh_towardzero (0x2.dp+4 + 0x1p+0 i)":
 double: 1
 idouble: 1
+ildouble: 1
+ldouble: 1
 Test "Imaginary part of: ctanh_towardzero (0x2.fp+4 + 0x1p+0 i)":
 ildouble: 1
 ldouble: 1
@@ -10921,6 +10937,75 @@ Test "exp10 (36)":
 double: 1
 idouble: 1
 
+# exp10_downward
+Test "exp10_downward (0x1.348e45573a1dd72cp+8)":
+ildouble: 2
+ldouble: 2
+Test "exp10_downward (0x2.4p+4)":
+double: 1
+idouble: 1
+Test "exp10_downward (0x3p+0)":
+ildouble: 1
+ldouble: 1
+
+# exp10_tonearest
+Test "exp10_tonearest (-0x1.31p+8)":
+double: 1
+idouble: 1
+Test "exp10_tonearest (-0x1p+0)":
+double: 1
+idouble: 1
+Test "exp10_tonearest (-0x2.4p+4)":
+double: 1
+idouble: 1
+Test "exp10_tonearest (0x2.4p+4)":
+double: 1
+idouble: 1
+Test "exp10_tonearest (0x3p+0)":
+double: 1
+idouble: 1
+Test "exp10_tonearest (0xcp-4)":
+ildouble: 1
+ldouble: 1
+
+# exp10_towardzero
+Test "exp10_towardzero (-0x1p+0)":
+ildouble: 1
+ldouble: 1
+Test "exp10_towardzero (0x1.344p+12)":
+ildouble: 1
+ldouble: 1
+Test "exp10_towardzero (0x2.4p+4)":
+double: 1
+idouble: 1
+
+# exp10_upward
+Test "exp10_upward (-0x1.344p+12)":
+float: 1
+ifloat: 1
+Test "exp10_upward (-0x1.86ap+16)":
+float: 1
+ifloat: 1
+Test "exp10_upward (-0xf.424p+16)":
+float: 1
+ifloat: 1
+Test "exp10_upward (-0xf.fffffp+124)":
+float: 1
+ifloat: 1
+Test "exp10_upward (0x1.344p+12)":
+ildouble: 1
+ldouble: 1
+Test "exp10_upward (0x2.4p+4)":
+double: 1
+idouble: 1
+Test "exp10_upward (0x3p+0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
 # exp_downward
 Test "exp_downward (0x2.c5cp+8)":
 ildouble: 1
@@ -11057,6 +11142,9 @@ idouble: 1
 Test "exp_upward (0x2.c5cp+8)":
 double: 1
 idouble: 1
+Test "exp_upward (0x2.c679d1f73f0fb628p+8)":
+ildouble: 1
+ldouble: 1
 Test "exp_upward (0x3.2p+4)":
 double: 1
 idouble: 1
@@ -16375,6 +16463,32 @@ idouble: 1
 ildouble: 1
 ldouble: 1
 
+Function: "exp10_downward":
+double: 1
+idouble: 1
+ildouble: 2
+ldouble: 2
+
+Function: "exp10_tonearest":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10_towardzero":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+
+Function: "exp10_upward":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
 Function: "exp_downward":
 double: 1
 float: 1