aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-04-30 18:56:39 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-04-30 18:56:39 +0000
commitadfbc8ac9e192b6e3007f7a47852df937afa2145 (patch)
tree09a345d547258a55e1d410065f9ca09a1bed480c /sysdeps
parent5ba3cc691c856e5c67a7d4cd4713f20a79f7ba81 (diff)
downloadglibc-adfbc8ac9e192b6e3007f7a47852df937afa2145.tar
glibc-adfbc8ac9e192b6e3007f7a47852df937afa2145.tar.gz
glibc-adfbc8ac9e192b6e3007f7a47852df937afa2145.tar.bz2
glibc-adfbc8ac9e192b6e3007f7a47852df937afa2145.zip
Fix x86 acos near 1 (bug 13942).
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/i386/fpu/e_acos.S10
-rw-r--r--sysdeps/i386/fpu/e_acosl.c8
-rw-r--r--sysdeps/i386/fpu/e_asin.S10
-rw-r--r--sysdeps/i386/fpu/libm-test-ulps12
-rw-r--r--sysdeps/x86_64/fpu/libm-test-ulps12
5 files changed, 41 insertions, 11 deletions
diff --git a/sysdeps/i386/fpu/e_acos.S b/sysdeps/i386/fpu/e_acos.S
index d10a054b9c..586c7fc406 100644
--- a/sysdeps/i386/fpu/e_acos.S
+++ b/sysdeps/i386/fpu/e_acos.S
@@ -7,13 +7,15 @@
RCSID("$NetBSD: e_acos.S,v 1.4 1995/05/08 23:44:37 jtc Exp $")
-/* acos = atan (sqrt(1 - x^2) / x) */
+/* acos = atan (sqrt((1-x) (1+x)) / x) */
ENTRY(__ieee754_acos)
fldl 4(%esp) /* x */
fld %st /* x : x */
- fmul %st(0) /* x^2 : x */
- fld1 /* 1 : x^2 : x */
- fsubp /* 1 - x^2 : x */
+ fld1 /* 1 : x : x */
+ fsubp /* 1 - x : x */
+ fld1 /* 1 : 1 - x : x */
+ fadd %st(2) /* 1 + x : 1 - x : x */
+ fmulp /* 1 - x^2 : x */
fsqrt /* sqrt (1 - x^2) : x */
fabs
fxch %st(1) /* x : sqrt (1 - x^2) */
diff --git a/sysdeps/i386/fpu/e_acosl.c b/sysdeps/i386/fpu/e_acosl.c
index d249d5a956..ab08931924 100644
--- a/sysdeps/i386/fpu/e_acosl.c
+++ b/sysdeps/i386/fpu/e_acosl.c
@@ -12,11 +12,13 @@ __ieee754_acosl (long double x)
{
long double res;
- /* acosl = atanl (sqrtl(1 - x^2) / x) */
+ /* acosl = atanl (sqrtl((1-x) (1+x)) / x) */
asm ( "fld %%st\n"
- "fmul %%st(0)\n" /* x^2 */
"fld1\n"
- "fsubp\n" /* 1 - x^2 */
+ "fsubp\n"
+ "fld1\n"
+ "fadd %%st(2)\n"
+ "fmulp\n" /* 1 - x^2 */
"fsqrt\n" /* sqrtl (1 - x^2) */
"fabs\n"
"fxch %%st(1)\n"
diff --git a/sysdeps/i386/fpu/e_asin.S b/sysdeps/i386/fpu/e_asin.S
index a17e922b6d..9a44cb62ac 100644
--- a/sysdeps/i386/fpu/e_asin.S
+++ b/sysdeps/i386/fpu/e_asin.S
@@ -7,13 +7,15 @@
RCSID("$NetBSD: e_asin.S,v 1.4 1995/05/08 23:45:40 jtc Exp $")
-/* asin = atan (x / sqrt(1 - x^2)) */
+/* asin = atan (x / sqrt((1-x) (1+x))) */
ENTRY(__ieee754_asin)
fldl 4(%esp) /* x */
fld %st
- fmul %st(0) /* x^2 */
- fld1
- fsubp /* 1 - x^2 */
+ fld1 /* 1 : x : x */
+ fsubp /* 1 - x : x */
+ fld1 /* 1 : 1 - x : x */
+ fadd %st(2) /* 1 + x : 1 - x : x */
+ fmulp /* 1 - x^2 */
fsqrt /* sqrt (1 - x^2) */
fpatan
ret
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index fdaff3525d..a49a69d4e9 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -80,6 +80,12 @@ ldouble: 1
Test "asin (-0.5) == -pi/6":
ildouble: 1
ldouble: 1
+Test "asin (-0x0.ffffffff8p0) == -1.5707810680058339712015850710748035974710":
+ildouble: 1
+ldouble: 1
+Test "asin (-0x0.ffffffp0) == -1.5704510598101804156437184421571127056013":
+ildouble: 1
+ldouble: 1
Test "asin (-1.0) == -pi/2":
ildouble: 1
ldouble: 1
@@ -89,6 +95,12 @@ ldouble: 1
Test "asin (0.75) == 0.848062078981481008052944338998418080":
ildouble: 1
ldouble: 1
+Test "asin (0x0.ffffffff8p0) == 1.5707810680058339712015850710748035974710":
+ildouble: 1
+ldouble: 1
+Test "asin (0x0.ffffffp0) == 1.5704510598101804156437184421571127056013":
+ildouble: 1
+ldouble: 1
Test "asin (1.0) == pi/2":
ildouble: 1
ldouble: 1
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 5068fe6952..9a1e80ed8d 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -55,6 +55,12 @@ ldouble: 1
Test "asin (-0.5) == -pi/6":
ildouble: 1
ldouble: 1
+Test "asin (-0x0.ffffffffffffffffp0) == -1.5707963264656243652399620683025688888978":
+ildouble: 1
+ldouble: 1
+Test "asin (-0x0.ffffffffffffp0) == -1.5707962425011995974432331617542781977068":
+ildouble: 1
+ldouble: 1
Test "asin (-1.0) == -pi/2":
ildouble: 1
ldouble: 1
@@ -64,6 +70,12 @@ ldouble: 1
Test "asin (0.75) == 0.848062078981481008052944338998418080":
ildouble: 1
ldouble: 1
+Test "asin (0x0.ffffffffffffffffp0) == 1.5707963264656243652399620683025688888978":
+ildouble: 1
+ldouble: 1
+Test "asin (0x0.ffffffffffffp0) == 1.5707962425011995974432331617542781977068":
+ildouble: 1
+ldouble: 1
Test "asin (1.0) == pi/2":
ildouble: 1
ldouble: 1