aboutsummaryrefslogtreecommitdiff
path: root/libquadmath
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-21 23:55:29 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-21 23:55:29 +0000
commit89a213c97ad0237409d3faf3ba320b981a397dad (patch)
treefc57edee06bfb00a7b2b91c9ea11ef86e3c7eec7 /libquadmath
parent43a0447f85401374b9f7a1370c496a06e7bb03e1 (diff)
2012-11-22 David S. Miller <davem@davemloft.net>
Tobias Burnus <burnus@net-b.de> Joseph Myers <joseph@codesourcery.com> * math/atanq.c (atanq): Update from GLIBC. Handle tiny and very large arguments properly. * math/j0q.c (y0q): Update from GLIBC. Avoid arithmetic underflow when 'x' is very small. * math/j1q.c (y1q): Ditto. * math/log1pq.c (log1pq): Update from GLIBC. Saturate nonzero exponents with absolute value below 0x1p-128 to +/- 0x1p-128. * math/powq.c (powq): Update from GLIBC. If xm1 is smaller than LDBL_EPSILON/2.0L, just return xm1. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193716 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libquadmath')
-rw-r--r--libquadmath/ChangeLog15
-rw-r--r--libquadmath/math/atanq.c17
-rw-r--r--libquadmath/math/j0q.c3
-rw-r--r--libquadmath/math/j1q.c4
-rw-r--r--libquadmath/math/log1pq.c6
-rw-r--r--libquadmath/math/powq.c6
6 files changed, 49 insertions, 2 deletions
diff --git a/libquadmath/ChangeLog b/libquadmath/ChangeLog
index b97a45868b3..ffd5927b72e 100644
--- a/libquadmath/ChangeLog
+++ b/libquadmath/ChangeLog
@@ -1,3 +1,18 @@
+2012-11-22 David S. Miller <davem@davemloft.net>
+ Tobias Burnus <burnus@net-b.de>
+ Joseph Myers <joseph@codesourcery.com>
+
+ * math/atanq.c (atanq): Update from GLIBC. Handle tiny and
+ very large arguments properly.
+ * math/j0q.c (y0q): Update from GLIBC. Avoid arithmetic
+ underflow when 'x' is very small.
+ * math/j1q.c (y1q): Ditto.
+ * math/log1pq.c (log1pq): Update from GLIBC. Saturate
+ nonzero exponents with absolute value below 0x1p-128 to
+ +/- 0x1p-128.
+ * math/powq.c (powq): Update from GLIBC. If xm1 is
+ smaller than LDBL_EPSILON/2.0L, just return xm1.
+
2012-11-21 Tobias Burnus <burnus@net-b.de>
PR libquadmath/55225
diff --git a/libquadmath/math/atanq.c b/libquadmath/math/atanq.c
index cb38a340a20..8eccdc3317d 100644
--- a/libquadmath/math/atanq.c
+++ b/libquadmath/math/atanq.c
@@ -167,6 +167,7 @@ static const __float128
q4 = 2.173623741810414221251136181221172551416E1Q;
/* q5 = 1.000000000000000000000000000000000000000E0 */
+static const long double huge = 1.0e4930Q;
__float128
atanq (__float128 x)
@@ -197,6 +198,22 @@ atanq (__float128 x)
return atantbl[83];
}
+ if (k <= 0x3fc50000) /* |x| < 2**-58 */
+ {
+ /* Raise inexact. */
+ if (huge + x > 0.0)
+ return x;
+ }
+
+ if (k >= 0x40720000) /* |x| > 2**115 */
+ {
+ /* Saturate result to {-,+}pi/2 */
+ if (sign)
+ return -atantbl[83];
+ else
+ return atantbl[83];
+ }
+
if (sign)
x = -x;
diff --git a/libquadmath/math/j0q.c b/libquadmath/math/j0q.c
index 3ef9201a8a4..8c6f811125e 100644
--- a/libquadmath/math/j0q.c
+++ b/libquadmath/math/j0q.c
@@ -807,6 +807,7 @@ static __float128 Y0_2D[NY0_2D + 1] = {
/* 1.000000000000000000000000000000000000000E0 */
};
+static const long double U0 = -7.3804295108687225274343927948483016310862e-02Q;
/* Bessel function of the second kind, order zero. */
@@ -829,6 +830,8 @@ y0q (__float128 x)
return -HUGE_VALQ + x;
}
xx = fabsq (x);
+ if (xx <= 0x1p-57)
+ return U0 + TWOOPI * logq (x);
if (xx <= 2.0Q)
{
/* 0 <= x <= 2 */
diff --git a/libquadmath/math/j1q.c b/libquadmath/math/j1q.c
index 8a18e2779b2..eb599c949a9 100644
--- a/libquadmath/math/j1q.c
+++ b/libquadmath/math/j1q.c
@@ -836,8 +836,10 @@ y1q (__float128 x)
return -HUGE_VALQ + x;
}
xx = fabsq (x);
+ if (xx <= 0x1p-114)
+ return -TWOOPI / x;
if (xx <= 2.0Q)
- {
+ {
/* 0 <= x <= 2 */
z = xx * xx;
p = xx * neval (z, Y0_2N, NY0_2N) / deval (z, Y0_2D, NY0_2D);
diff --git a/libquadmath/math/log1pq.c b/libquadmath/math/log1pq.c
index 2de13fe2adc..d8bff405dff 100644
--- a/libquadmath/math/log1pq.c
+++ b/libquadmath/math/log1pq.c
@@ -136,6 +136,12 @@ log1pq (__float128 xm1)
&& (u.words32.w1 | u.words32.w2 | u.words32.w3) == 0)
return xm1;
+ if ((hx & 0x7fffffff) < 0x3f8e0000)
+ {
+ if ((int) xm1 == 0)
+ return xm1;
+ }
+
x = xm1 + 1.0Q;
/* log1p(-1) = -inf */
diff --git a/libquadmath/math/powq.c b/libquadmath/math/powq.c
index 12b87d536d7..dd44b7c175a 100644
--- a/libquadmath/math/powq.c
+++ b/libquadmath/math/powq.c
@@ -148,7 +148,7 @@ powq (__float128 x, __float128 y)
{
__float128 z, ax, z_h, z_l, p_h, p_l;
__float128 y1, t1, t2, r, s, t, u, v, w;
- __float128 s2, s_h, s_l, t_h, t_l;
+ __float128 s2, s_h, s_l, t_h, t_l, ay;
int32_t i, j, k, yisint, n;
uint32_t ix, iy;
int32_t hx, hy;
@@ -281,6 +281,10 @@ powq (__float128 x, __float128 y)
return (hy > 0) ? huge * huge : tiny * tiny;
}
+ ay = y > 0 ? y : -y;
+ if (ay < 0x1p-128)
+ y = y < 0 ? -0x1p-128 : 0x1p-128;
+
n = 0;
/* take care subnormal number */
if (ix < 0x00010000)