aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386
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/i386
parent31e3a40588f6b215f2583c12ba29ff5cea63d2ef (diff)
downloadglibc-5b0626b9c50e69fe4d7dce90199d78f398c249b1.zip
glibc-5b0626b9c50e69fe4d7dce90199d78f398c249b1.tar.gz
glibc-5b0626b9c50e69fe4d7dce90199d78f398c249b1.tar.bz2
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/i386')
-rw-r--r--sysdeps/i386/fpu/e_expl.S4
-rw-r--r--sysdeps/i386/fpu/libm-test-ulps114
2 files changed, 109 insertions, 9 deletions
diff --git a/sysdeps/i386/fpu/e_expl.S b/sysdeps/i386/fpu/e_expl.S
index a8a5e70..5917f57 100644
--- a/sysdeps/i386/fpu/e_expl.S
+++ b/sysdeps/i386/fpu/e_expl.S
@@ -130,7 +130,6 @@ 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. */
subl $8, %esp
cfi_adjust_cfa_offset (8)
@@ -139,15 +138,12 @@ ENTRY(IEEE754_EXPL)
andl 4(%esp), %edx
movl %edx, (%esp)
fldcw (%esp)
-#endif
frndint /* 1 i */
fld %st(1) /* 2 x */
frndint /* 2 xi */
-#ifdef USE_AS_EXPM1L
fldcw 4(%esp)
addl $8, %esp
cfi_adjust_cfa_offset (-8)
-#endif
fld %st(1) /* 3 i */
fldt MO(c0) /* 4 c0 */
fld %st(2) /* 5 xi */
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index dc53d94..ae0a303 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -7095,6 +7095,10 @@ Test "cosh_downward (-0x2.c5e3bp+8)":
ildouble: 1
Test "cosh_downward (-0x2.c679d1f73f0fap+8)":
ildouble: 2
+Test "cosh_downward (-0x2.c679d1f73f0fb624p+8)":
+ildouble: 2
+Test "cosh_downward (-0x2.c679d1f73f0fb628p+8)":
+ildouble: 2
Test "cosh_downward (-0x2.c679d1f73f0fcp+8)":
ildouble: 1
Test "cosh_downward (-0x2.c679dp+8)":
@@ -7181,15 +7185,25 @@ Test "cosh_towardzero (-0x2.c5d37700c6bbp+12)":
ldouble: 2
Test "cosh_towardzero (-0x2.c5e3acd2922a6p+8)":
ildouble: 1
+Test "cosh_towardzero (-0x2.c679d1f73f0fap+8)":
+ildouble: 2
+Test "cosh_towardzero (-0x2.c679d1f73f0fb624p+8)":
+ildouble: 2
+Test "cosh_towardzero (-0x2.c679d1f73f0fb628p+8)":
+ildouble: 2
Test "cosh_towardzero (-0x2.c679dp+8)":
double: 1
ildouble: 1
Test "cosh_towardzero (-0x5.96a7ep+4)":
double: 1
+ildouble: 2
ldouble: 1
Test "cosh_towardzero (0x1.6p+4)":
ildouble: 1
ldouble: 2
+Test "cosh_towardzero (0x1.8p+4)":
+ildouble: 1
+ldouble: 1
Test "cosh_towardzero (0x2.c5d374p+12)":
ldouble: 1
Test "cosh_towardzero (0x2.c5d37700c6bb03a4p+12)":
@@ -7240,6 +7254,11 @@ ildouble: 1
Test "cosh_upward (-0x2.c679d1f73f0fap+8)":
double: 1
ildouble: 1
+Test "cosh_upward (-0x2.c679d1f73f0fb624p+8)":
+ildouble: 1
+Test "cosh_upward (-0x2.c679d1f73f0fb628p+8)":
+ildouble: 1
+ldouble: 1
Test "cosh_upward (-0x2.c679d1f73f0fcp+8)":
ildouble: 1
Test "cosh_upward (-0x2p-16384)":
@@ -7292,6 +7311,11 @@ ildouble: 1
Test "cosh_upward (0x2.c679d1f73f0fap+8)":
double: 1
ildouble: 1
+Test "cosh_upward (0x2.c679d1f73f0fb624p+8)":
+ildouble: 1
+Test "cosh_upward (0x2.c679d1f73f0fb628p+8)":
+ildouble: 2
+ldouble: 1
Test "cosh_upward (0x2.c679d1f73f0fcp+8)":
ildouble: 1
Test "cosh_upward (0x2.c679d4p+8)":
@@ -8323,11 +8347,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)":
double: 1
idouble: 1
@@ -8361,6 +8387,9 @@ double: 1
idouble: 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: 1
idouble: 1
@@ -9188,8 +9217,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: 1
idouble: 1
@@ -9235,6 +9264,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)":
double: 1
idouble: 1
@@ -9697,6 +9728,48 @@ Test "exp10 (0xcp-4)":
ildouble: 1
ldouble: 1
+# exp10_downward
+Test "exp10_downward (0x1.348e45573a1dd72cp+8)":
+ildouble: 2
+ldouble: 2
+Test "exp10_downward (0x3p+0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+
+# exp10_tonearest
+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 (0x3p+0)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+
+# exp10_upward
+Test "exp10_upward (0x1.344p+12)":
+ildouble: 1
+ldouble: 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)":
double: 1
@@ -9788,6 +9861,9 @@ ldouble: 1
Test "exp_upward (-0x2.e870a7e5e88cp+8)":
ildouble: 1
ldouble: 1
+Test "exp_upward (0x2.c679d1f73f0fb628p+8)":
+ildouble: 1
+ldouble: 1
Test "exp_upward (1)":
double: 1
float: 1
@@ -14500,7 +14576,7 @@ double: 1
float: 1
idouble: 1
ifloat: 1
-ildouble: 1
+ildouble: 2
ldouble: 3
Function: "cosh_upward":
@@ -14740,6 +14816,34 @@ Function: "exp10":
ildouble: 1
ldouble: 1
+Function: "exp10_downward":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: "exp10_tonearest":
+ildouble: 1
+ldouble: 1
+
+Function: "exp10_towardzero":
+double: 1
+float: 1
+idouble: 1
+ifloat: 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