From cb0937b299182e78307795081489ec1f148bdbd7 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sun, 21 Jun 2015 18:43:10 +0000 Subject: Fix x86_64 / x86 expm1l (-min_subnorm) result sign (bug 18569). 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. [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. --- sysdeps/x86_64/fpu/e_expl.S | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sysdeps/x86_64/fpu/e_expl.S') diff --git a/sysdeps/x86_64/fpu/e_expl.S b/sysdeps/x86_64/fpu/e_expl.S index 866bad2c6e..14dd29dcad 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 -- cgit v1.2.3