This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix x86_64 / x86 expm1l (-min_subnorm) result sign (bug 18569) [committed]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Sun, 21 Jun 2015 18:43:47 +0000
- Subject: Fix x86_64 / x86 expm1l (-min_subnorm) result sign (bug 18569) [committed]
- Authentication-results: sourceware.org; auth=none
In the x86 / x86_64 implementations of expm1l, when expm1l's result
should underflow to 0 (argument minus the least subnormal, in some
rounding modes), it can be a zero of the wrong sign. This patch fixes
this by returning the argument with underflow forced in that case
(this is a 1ulp error relative to the correctly rounded result of -0,
which is OK in terms of the documented accuracy goals, whereas a
result with the wrong sign never is).
Tested for x86_64 and x86. Committed.
(auto-libm-test-out changes omitted below.)
2015-06-21 Joseph Myers <joseph@codesourcery.com>
[BZ #18569]
* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]: Force
underflow and return argument in case of subnormal argument.
* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]:
Likewise.
* math/auto-libm-test-in: Add more tests of expm1.
* math/auto-libm-test-out: Regenerated.
diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index e8e4da6..6b05459 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -1364,6 +1364,10 @@ expm1 0x5.fb8dc64e91a74p-4
expm1 0x3.735f497c4e67535cp-4
# Bug 16353: underflow exception may be missing
expm1 0x4.0000000000000028p-16384 missing-underflow
+expm1 min missing-underflow
+expm1 -min missing-underflow
+expm1 min_subnorm missing-underflow
+expm1 -min_subnorm missing-underflow
fma 1.0 2.0 3.0
fma 1.25 0.75 0.0625
diff --git a/sysdeps/i386/fpu/e_expl.S b/sysdeps/i386/fpu/e_expl.S
index 74968bb..711c86a 100644
--- a/sysdeps/i386/fpu/e_expl.S
+++ b/sysdeps/i386/fpu/e_expl.S
@@ -122,6 +122,12 @@ ENTRY(IEEE754_EXPL)
normal. */
cmpl $0x0001, %eax
jge 2f
+ /* Force underflow and return the argument, to avoid wrong signs
+ of zero results from the code below in some rounding modes. */
+ fld %st
+ fmul %st
+ fstp %st
+ jmp 2f
#else
movzwl 4+8(%esp), %eax
andl $0x7fff, %eax
diff --git a/sysdeps/x86_64/fpu/e_expl.S b/sysdeps/x86_64/fpu/e_expl.S
index 866bad2..14dd29d 100644
--- a/sysdeps/x86_64/fpu/e_expl.S
+++ b/sysdeps/x86_64/fpu/e_expl.S
@@ -119,6 +119,12 @@ ENTRY(IEEE754_EXPL)
normal. */
cmpl $0x0001, %eax
jge 2f
+ /* Force underflow and return the argument, to avoid wrong signs
+ of zero results from the code below in some rounding modes. */
+ fld %st
+ fmul %st
+ fstp %st
+ jmp 2f
#else
movzwl 8+8(%rsp), %eax
andl $0x7fff, %eax
--
Joseph S. Myers
joseph@codesourcery.com