This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix i386 atanhl spurious underflows (bug 18049) [committed]


The i386 implementation of atanhl, for small arguments, does a
calculation that involves computing twice the square of the argument,
resulting in spurious underflows for some arguments.  This patch fixes
this by just returning the argument when its exponent is below -32,
with underflow being forced as needed for subnormal arguments.

Tested for x86 and x86_64.  Committed.

(auto-libm-test-out diffs omitted below.)

2015-05-19  Joseph Myers  <joseph@codesourcery.com>

	[BZ #18049]
	* sysdeps/i386/fpu/e_atanhl.S (__ieee754_atanhl): For exponents
	below -32, return the argument, with underflow if subnormal.
	* math/auto-libm-test-in: Add more tests of atanh.
	* math/auto-libm-test-out: Regenerated.

diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index 6fe0ed7..9e55d91 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -368,6 +368,11 @@ atanh 0x1p-57
 atanh 0x1p-58
 atanh 0x1p-59
 atanh 0x1p-100
+atanh -0x1p-100
+atanh 0x1p-600
+atanh -0x1p-600
+atanh 0x1p-10000
+atanh -0x1p-10000
 atanh -0x6.e6c77p-20
 atanh 0x3.2ca824p-4
 atanh -0x1.cc1d66p-4
diff --git a/sysdeps/i386/fpu/e_atanhl.S b/sysdeps/i386/fpu/e_atanhl.S
index 88a9703..1ad6851 100644
--- a/sysdeps/i386/fpu/e_atanhl.S
+++ b/sysdeps/i386/fpu/e_atanhl.S
@@ -56,6 +56,16 @@ ENTRY(__ieee754_atanhl)
 	andl	$0x7fff, %eax
 	cmpl	$0x7fff, %eax
 	je	5f
+	cmpl	$0x3fdf, %eax
+	jge	7f
+	// Exponent below -32; return x, with underflow if subnormal.
+	fldt	4(%esp)
+	cmpl	$0, %eax
+	jne	8f
+	fld	%st(0)
+	fmul	%st(0)
+	fstp	%st(0)
+8:	ret
 7:
 
 #ifdef PIC

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]