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 ldbl-128 logl for subnormals (bug 16338)


This patch fixes bug 16338, ldbl-128 logl not handling subnormals
(with consequent inaccuracy for lgammal as well).  The fix is simply
to use __frexpl when determining the exponent, as done already in
log2l and log10l.  Given the lack of testing of small arguments to any
of the log* functions, appropriate tests are added for all of them.

Tested x86_64 and ulps updated accordingly, and spot tests also run
for mips64 to confirm the ldbl-128 fix.

Note that while this fixes lgammal inaccuracy for small positive
arguments (the problems for small negative arguments being bug 16337),
I suspect that there will still be problems with spurious underflows
in the case of small positive arguments.  If someone testing on an
ldbl-128 system supporting exceptions (such as SPARC or AArch64) could
confirm this and file a bug, then I can deal with that alongside bug
16337.

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

2013-12-18  Joseph Myers  <joseph@codesourcery.com>

	[BZ #16338]
	* sysdeps/ieee754/ldbl-128/e_logl.c (__ieee754_logl): Use __frexpl
	to determine exponent and adjust argument to have exponent of -1.
	* math/auto-libm-test-in: Add more tests of log, log10, log1p and
	log2.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update.

diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index dd4fd22..30e1ec6 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -414,6 +414,8 @@ log 1/e
 log 2
 log 10
 log 0.75
+log min
+log min_subnorm
 
 log10 1
 log10 0.1
@@ -422,12 +424,19 @@ log10 100.0
 log10 10000.0
 log10 e
 log10 0.75
+log10 min
+log10 min_subnorm
 
 log1p 0
 log1p -0
 log1p e-1
 log1p -0.25
 log1p -0.875
+# Bug 16339: underflow exception may be missing.
+log1p min missing-underflow
+log1p min_subnorm missing-underflow
+log1p -min missing-underflow
+log1p -min_subnorm missing-underflow
 
 log2 1
 log2 e
@@ -435,6 +444,8 @@ log2 2.0
 log2 16.0
 log2 256.0
 log2 0.75
+log2 min
+log2 min_subnorm
 
 pow 0 0
 pow 0 -0
diff --git a/sysdeps/ieee754/ldbl-128/e_logl.c b/sysdeps/ieee754/ldbl-128/e_logl.c
index 395a763..3d1034d 100644
--- a/sysdeps/ieee754/ldbl-128/e_logl.c
+++ b/sysdeps/ieee754/ldbl-128/e_logl.c
@@ -212,9 +212,8 @@ __ieee754_logl(long double x)
     }
 
   /* Extract exponent and reduce domain to 0.703125 <= u < 1.40625  */
-  e = (int) (m >> 16) - (int) 0x3ffe;
-  m &= 0xffff;
-  u.parts32.w0 = m | 0x3ffe0000;
+  u.value = __frexpl (x, &e);
+  m = u.parts32.w0 & 0xffff;
   m |= 0x10000;
   /* Find lookup table index k from high order bits of the significand. */
   if (m < 0x16800)
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 3985945..d36b76a 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -7675,6 +7675,9 @@ ldouble: 1
 Test "log10 (0x2.b7e154p+0)":
 float: 1
 ifloat: 1
+Test "log10 (0x4p-128)":
+ildouble: 1
+ldouble: 1
 Test "log10 (0xcp-4)":
 double: 1
 float: 2

-- 
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]