From 8c6c9236361fbc077769673c259828216403bc33 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Wed, 30 Sep 2015 21:44:42 +0000 Subject: Fix i386 acosh (-qNaN) spurious "invalid" exception. The i386 versions of acoshf and acosh raise a spurious "invalid" exception for an argument that is a quiet NaN with the sign bit set. The integer arithmetic to detect arguments < 1 also detects -NaN, and then the computation 0 / 0 in that case raises the exception. This patch fixes this by using (x - x) / (x - x) as the computation in that case instead, which will always raise the exception for non-NaN arguments reaching that code, but not for quiet NaN arguments. Tested for x86_64 and x86. [BZ #19032] * sysdeps/i386/fpu/e_acosh.S (__ieee754_acosh): For arguments < 1, compute result as (x - x) / (x - x) not as 0 / 0. * sysdeps/i386/fpu/e_acoshf.S (__ieee754_acoshf): Likewise. * math/libm-test.inc (acosh_test_data): Add another test of acosh. --- sysdeps/i386/fpu/e_acosh.S | 5 +++-- sysdeps/i386/fpu/e_acoshf.S | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'sysdeps/i386') diff --git a/sysdeps/i386/fpu/e_acosh.S b/sysdeps/i386/fpu/e_acosh.S index c5cd4474ec..263c01a4ed 100644 --- a/sysdeps/i386/fpu/e_acosh.S +++ b/sysdeps/i386/fpu/e_acosh.S @@ -91,9 +91,10 @@ ENTRY(__ieee754_acosh) fyl2x // log(2*x+1/(x+sqrt(x^2-1))) ret - // x < 1 => NaN + // x < 1 (or -NaN) => NaN .align ALIGNARG(4) -5: fldz +5: fldl 4(%esp) + fsub %st fdiv %st, %st(0) ret END(__ieee754_acosh) diff --git a/sysdeps/i386/fpu/e_acoshf.S b/sysdeps/i386/fpu/e_acoshf.S index 710267b11e..779a02cfab 100644 --- a/sysdeps/i386/fpu/e_acoshf.S +++ b/sysdeps/i386/fpu/e_acoshf.S @@ -91,9 +91,10 @@ ENTRY(__ieee754_acoshf) fyl2x // log(2*x+1/(x+sqrt(x^2-1))) ret - // x < 1 => NaN + // x < 1 (or -NaN) => NaN .align ALIGNARG(4) -5: fldz +5: flds 4(%esp) + fsub %st fdiv %st, %st(0) ret END(__ieee754_acoshf) -- cgit 1.4.1