This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Irix6 long doubles implemented wrong? (27_io/ostream_inserter_arith)
On Jan 26, 2003, Alexandre Oliva <aoliva@redhat.com> wrote:
> * real.c (ibm_extended_format): Add 53 to minimum exponent.
Turned out this got encode_ibm_extended very confused when presented
with denormals, not only numbers that had to be represented as
denormal doubles, but also those that could still use a normal double
for the upper part. This new patch fixes it, and actually passes the
numeric_limits test. Ok to install?
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* real.c (ibm_extended_format): Add 53 to minimum exponent.
(encode_ibm_extended): Adjust.
Index: gcc/real.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/real.c,v
retrieving revision 1.105
diff -u -p -r1.105 real.c
--- gcc/real.c 17 Nov 2002 20:20:39 -0000 1.105
+++ gcc/real.c 26 Jan 2003 12:43:40 -0000
@@ -1,6 +1,6 @@
/* real.c - software floating point emulation.
Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2002 Free Software Foundation, Inc.
+ 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
Contributed by Stephen L. Moshier (moshier@world.std.com).
Re-written by Richard Henderson <rth@redhat.com>
@@ -3254,8 +3254,23 @@ encode_ibm_extended (fmt, buf, r)
u = *r;
clear_significand_below (&u, SIGNIFICAND_BITS - 53);
- /* v = remainder containing additional 53 bits of significand. */
- do_add (&v, r, &u, 1);
+ normalize (&u);
+ /* If the upper double is zero, we have a denormal double, so
+ move it to the first double and leave the second as zero. */
+ if (u.class == rvc_zero)
+ {
+ v = u;
+ u = *r;
+ normalize (&u);
+ }
+ else
+ {
+ /* v = remainder containing additional 53 bits of significand. */
+ do_add (&v, r, &u, 1);
+ round_for_format (&ieee_double_format, &v);
+ }
+
+ round_for_format (&ieee_double_format, &u);
encode_ieee_double (&ieee_double_format, &buf[0], &u);
encode_ieee_double (&ieee_double_format, &buf[2], &v);
@@ -3292,7 +3307,7 @@ const struct real_format ibm_extended_fo
2,
1,
53 + 53,
- -1021,
+ -1021 + 53,
1024,
true,
true,
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer