aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-03-21 18:13:58 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-03-21 18:13:58 +0000
commitf7be737659813220e1f29c8850c386a9654d549a (patch)
treec047f314e8eca5df155322e4fe9471593fb07b67 /sysdeps/i386
parenta387428ca7330513d5f2a0924c45e6382d477052 (diff)
downloadglibc-f7be737659813220e1f29c8850c386a9654d549a.zip
glibc-f7be737659813220e1f29c8850c386a9654d549a.tar.gz
glibc-f7be737659813220e1f29c8850c386a9654d549a.tar.bz2
Fix log (1) in round-downward mode (bug 16731).
According to ISO C Annex F, log (1) should be +0 in all rounding modes, but some implementations in glibc wrongly return -0 in round-downward mode (mapping to log1p (x - 1) is problematic because 1 - 1 is -0 in round-downward mode, and log1p (-0) is -0). This patch fixes this. (It helps with some implementations of other functions such as acosh, log2 and log10 that call out to log, but not enough to enable all-rounding-modes testing for those functions without further fixes to other implementations of them.) Tested x86_64 and x86 and ulps updated accordingly, and did spot tests for mips64 for the ldbl-128 fix, and i586 for the sysdeps/i386/fpu implementations shadowed by those in sysdeps/i386/i686/fpu. [BZ #16731] * sysdeps/i386/fpu/e_log.S (__ieee754_log): Take absolute value when x - 1 is zero. * sysdeps/i386/fpu/e_logf.S (__ieee754_logf): Likewise. * sysdeps/i386/fpu/e_logl.S (__ieee754_logl): Likewise. * sysdeps/i386/i686/fpu/e_logl.S (__ieee754_logl): Likewise. * sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Return +0 when argument is 1. * sysdeps/ieee754/ldbl-128/e_logl.c (__ieee754_logl): Likewise. * sysdeps/x86_64/fpu/e_logl.S: Take absolute value when x - 1 is zero. * math/libm-test.inc (log_test): Use ALL_RM_TEST. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/fpu/e_log.S8
-rw-r--r--sysdeps/i386/fpu/e_logf.S8
-rw-r--r--sysdeps/i386/fpu/e_logl.S8
-rw-r--r--sysdeps/i386/fpu/libm-test-ulps12
-rw-r--r--sysdeps/i386/i686/fpu/e_logl.S8
5 files changed, 40 insertions, 4 deletions
diff --git a/sysdeps/i386/fpu/e_log.S b/sysdeps/i386/fpu/e_log.S
index 0877924..3fa32aa 100644
--- a/sysdeps/i386/fpu/e_log.S
+++ b/sysdeps/i386/fpu/e_log.S
@@ -46,7 +46,13 @@ ENTRY(__ieee754_log)
fnstsw // x-1 : x : log(2)
andb $0x45, %ah
jz 2f
- fstp %st(1) // x-1 : log(2)
+ fxam
+ fnstsw
+ andb $0x45, %ah
+ cmpb $0x40, %ah
+ jne 5f
+ fabs // log(1) is +0 in all rounding modes.
+5: fstp %st(1) // x-1 : log(2)
fyl2xp1 // log(x)
ret
diff --git a/sysdeps/i386/fpu/e_logf.S b/sysdeps/i386/fpu/e_logf.S
index 485180e..ca83d39 100644
--- a/sysdeps/i386/fpu/e_logf.S
+++ b/sysdeps/i386/fpu/e_logf.S
@@ -47,7 +47,13 @@ ENTRY(__ieee754_logf)
fnstsw // x-1 : x : log(2)
andb $0x45, %ah
jz 2f
- fstp %st(1) // x-1 : log(2)
+ fxam
+ fnstsw
+ andb $0x45, %ah
+ cmpb $0x40, %ah
+ jne 5f
+ fabs // log(1) is +0 in all rounding modes.
+5: fstp %st(1) // x-1 : log(2)
fyl2xp1 // log(x)
ret
diff --git a/sysdeps/i386/fpu/e_logl.S b/sysdeps/i386/fpu/e_logl.S
index d7a459a..edae1d7 100644
--- a/sysdeps/i386/fpu/e_logl.S
+++ b/sysdeps/i386/fpu/e_logl.S
@@ -47,7 +47,13 @@ ENTRY(__ieee754_logl)
fnstsw // x-1 : x : log(2)
andb $0x45, %ah
jz 2f
- fstp %st(1) // x-1 : log(2)
+ fxam
+ fnstsw
+ andb $0x45, %ah
+ cmpb $0x40, %ah
+ jne 5f
+ fabs // log(1) is +0 in all rounding modes.
+5: fstp %st(1) // x-1 : log(2)
fyl2xp1 // log(x)
ret
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index 3be1806..b7b2e12 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -1096,6 +1096,18 @@ Function: "log1p":
ildouble: 1
ldouble: 1
+Function: "log_downward":
+ildouble: 1
+ldouble: 1
+
+Function: "log_towardzero":
+ildouble: 1
+ldouble: 1
+
+Function: "log_upward":
+ildouble: 1
+ldouble: 1
+
Function: "pow":
ildouble: 1
ldouble: 1
diff --git a/sysdeps/i386/i686/fpu/e_logl.S b/sysdeps/i386/i686/fpu/e_logl.S
index 8a86222..a0d1107 100644
--- a/sysdeps/i386/i686/fpu/e_logl.S
+++ b/sysdeps/i386/i686/fpu/e_logl.S
@@ -46,7 +46,13 @@ ENTRY(__ieee754_logl)
fcomip %st(1) // |x-1| : x-1 : x : log(2)
fstp %st(0) // x-1 : x : log(2)
jc 2f
- fstp %st(1) // x-1 : log(2)
+ fxam
+ fnstsw
+ andb $0x45, %ah
+ cmpb $0x40, %ah
+ jne 4f
+ fabs // log(1) is +0 in all rounding modes.
+4: fstp %st(1) // x-1 : log(2)
fyl2xp1 // log(x)
ret