diff options
author | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-10 05:47:14 +0000 |
---|---|---|
committer | geoffk <geoffk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-01-10 05:47:14 +0000 |
commit | 2ce081b770e429fdf14e53cbec975823a44e0564 (patch) | |
tree | d30bf7e4c2a8d092733cec701722dc75f1fb8112 /gcc/config/rs6000/darwin-ldouble.c | |
parent | 11d99e06a52067db2d0faf32ed7d1f2144bb99d9 (diff) | |
download | gcc-2ce081b770e429fdf14e53cbec975823a44e0564.tar.gz |
* config/rs6000/darwin-ldouble.c: Add big comment explaining
exactly what is expected as a 'long double'.
(_xlqadd): When a value to be returned is representable as a
'double', just return it directly, do not construct it using a union.
Also, correct final fixup.
(_xlqmul): Likewise.
(_xlqdiv): Likewise.
* real.c (encode_ibm_extended): Make consistent with darwin-ldouble.c.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75629 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/rs6000/darwin-ldouble.c')
-rw-r--r-- | gcc/config/rs6000/darwin-ldouble.c | 66 |
1 files changed, 23 insertions, 43 deletions
diff --git a/gcc/config/rs6000/darwin-ldouble.c b/gcc/config/rs6000/darwin-ldouble.c index 281eb2a7599..c73b24f5270 100644 --- a/gcc/config/rs6000/darwin-ldouble.c +++ b/gcc/config/rs6000/darwin-ldouble.c @@ -37,6 +37,17 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA Floating-Point Computations", by Seppo Linnainmaa, ACM TOMS vol 7 no 3, September 1961, pages 272-283. */ +/* Each long double is made up of two IEEE doubles. The value of the + long double is the sum of the values of the two parts. The most + significant part is required to be the value of the long double + rounded to the nearest double, as specified by IEEE. For Inf + values, the least significant part is required to be one of +0.0 or + -0.0. No other requirements are made; so, for example, 1.0 may be + represented as (1.0, +0.0) or (1.0, -0.0), and the low part of a + NaN is don't-care. + + This code currently assumes big-endian. */ + #define fabs(x) __builtin_fabs(x) #define unlikely(x) __builtin_expect ((x), 0) @@ -68,11 +79,8 @@ _xlqadd (double a, double b, double c, double d) FPR_zero = 0.0; FPR_PosInf = FPKINF; - if (unlikely (a != a) || unlikely (c != c)) { - z.dval[0] = a + c; /* NaN result. */ - z.dval[1] = a + c; /* NaN result. */ - return z.ldval; - } + if (unlikely (a != a) || unlikely (c != c)) + return a + c; /* NaN result. */ /* Ordered operands are arranged in order of their magnitudes. */ @@ -110,18 +118,14 @@ _xlqadd (double a, double b, double c, double d) t = (tau + b) + a; /* Sum values in ascending magnitude order. */ /* Infinite or zero result. */ - if (unlikely (fabs (t) == FPR_PosInf) || unlikely (t == FPR_zero)) - { - z.dval[0] = t; - z.dval[1] = t >= 0.0 ? (fabs (t) >= 0.0 ? t : 0.0) : -0.0; - return z.ldval; - } + if (unlikely (t == FPR_zero) || unlikely (fabs (t) == FPR_PosInf)) + return t; /* Usual case. */ tau = (((a-t) + b) + c) + d; u = t + tau; z.dval[0] = u; /* Final fixup for long double result. */ - z.dval[1] = (u - t) + tau; + z.dval[1] = (t - u) + tau; return z.ldval; } @@ -142,22 +146,10 @@ _xlqmul (double a, double b, double c, double d) t = a * c; /* Highest order double term. */ - if (unlikely (t != t) || unlikely (t == FPR_zero)) - { - /* NaN or zero result. */ - z.dval[0] = t; - z.dval[1] = t; - return z.ldval; - } + if (unlikely (t != t) || unlikely (t == FPR_zero) + || unlikely (fabs (t) == FPR_PosInf)) + return t; - if (unlikely (fabs(t) == FPR_PosInf)) - { - /* Infinite result. */ - z.dval[0] = t; - z.dval[1] = t >= 0 ? 0.0 : -0.0; - return z.ldval; - } - /* Finite nonzero result requires summing of terms of two highest orders. */ @@ -170,7 +162,7 @@ _xlqmul (double a, double b, double c, double d) /* Construct long double result. */ z.dval[0] = u; - z.dval[1] = (u - t) + tau; + z.dval[1] = (t - u) + tau; return z.ldval; } @@ -185,21 +177,9 @@ _xlqdiv (double a, double b, double c, double d) t = a / c; /* highest order double term */ - if (unlikely (t != t) || unlikely (t == FPR_zero)) - { - /* NaN or zero result. */ - z.dval[0] = t; - z.dval[1] = t; - return z.ldval; - } - - if (unlikely (fabs (t) == FPR_PosInf)) - { - /* Infinite result. */ - z.dval[0] = t; - z.dval[1] = t >= 0.0 ? 0.0 : -0.0; - return z.ldval; - } + if (unlikely (t != t) || unlikely (t == FPR_zero) + || unlikely (fabs (t) == FPR_PosInf)) + return t; /* Finite nonzero result requires corrections to the highest order term. */ |