From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32432 invoked by alias); 26 Jan 2003 10:07:34 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 32404 invoked from network); 26 Jan 2003 10:07:32 -0000 Received: from unknown (HELO monty-python.gnu.org) (199.232.76.173) by 172.16.49.205 with SMTP; 26 Jan 2003 10:07:32 -0000 Received: from nat-pool-rdu.redhat.com ([66.187.233.200] helo=lacrosse.corp.redhat.com) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18cjhG-0001Nb-00; Sun, 26 Jan 2003 05:07:26 -0500 Received: from free.redhat.lsd.ic.unicamp.br (aoliva.cipe.redhat.com [10.0.1.10]) by lacrosse.corp.redhat.com (8.11.6/8.9.3) with ESMTP id h0QA6Dg26688; Sun, 26 Jan 2003 05:06:13 -0500 Received: from free.redhat.lsd.ic.unicamp.br (localhost.localdomain [127.0.0.1]) by free.redhat.lsd.ic.unicamp.br (8.12.7/8.12.7) with ESMTP id h0QA6CfZ009993; Sun, 26 Jan 2003 08:06:12 -0200 Received: (from aoliva@localhost) by free.redhat.lsd.ic.unicamp.br (8.12.7/8.12.7/Submit) id h0QA65QV009989; Sun, 26 Jan 2003 08:06:05 -0200 To: "Kaveh R. Ghazi" Cc: gcc-bugs@gcc.gnu.org, gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org, libstdc++@gcc.gnu.org, oldham@codesourcery.com, ro@TechFak.Uni-Bielefeld.DE, rth@redhat.com Subject: Re: Irix6 long doubles implemented wrong? (27_io/ostream_inserter_arith) References: <200212170531.AAA15561@caip.rutgers.edu> <200212241434.JAA22361@caip.rutgers.edu> <20030107221549.GR12992@redhat.com> <20030110011352.GF9245@redhat.com> <200301191731.MAA18215@caip.rutgers.edu> From: Alexandre Oliva Organization: GCC Team, Red Hat Date: Sun, 26 Jan 2003 13:00:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SW-Source: 2003-01/txt/msg01272.txt.bz2 --=-=-= Content-length: 571 On Jan 19, 2003, Alexandre Oliva wrote: > the minimum normal exponent should be set such that all 107 > significant bits are available (and it's 107, not 106, as I > implemented it) for normals. It can't possibly be 107. IRIX must be doing something wrong in setting LDBL_MANT_DIG to 107, since there are only 53 bits of precision in each double, even if you count the implicit 1s. Besides, the emulation I implemented worked correctly down to the least significant bits with IRIX's printf, so I'm checking these bits in too, per rth's approval. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=gcc-mips-tfmode-fp-bit-ibmext.patch Content-length: 4851 Index: gcc/ChangeLog from Alexandre Oliva * fp-bit.h: Define macros for TFmode floating-point constants in IBM-extended TFmode types. (TMODES): Define if __LDBL_MANT_DIG__ has the newly-supported widths. * config/fp-bit.c (pack_d, unpack_d): Support IBM-extended TFmode type. Index: gcc/config/fp-bit.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/fp-bit.c,v retrieving revision 1.36.4.1 diff -u -p -r1.36.4.1 fp-bit.c --- gcc/config/fp-bit.c 26 Jan 2003 09:30:38 -0000 1.36.4.1 +++ gcc/config/fp-bit.c 26 Jan 2003 10:01:20 -0000 @@ -322,9 +322,66 @@ pack_d ( fp_number_type * src) dst.bits.exp = exp; dst.bits.sign = sign; #else +# if defined TFLOAT && defined HALFFRACBITS + { + halffractype high, low; + + high = (fraction >> (FRACBITS - HALFFRACBITS)); + high &= (((fractype)1) << HALFFRACBITS) - 1; + high |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << HALFFRACBITS; + high |= ((fractype) (sign & 1)) << (HALFFRACBITS | EXPBITS); + + low = (halffractype)fraction & + ((((halffractype)1) << (FRACBITS - HALFFRACBITS)) - 1); + + if (exp == EXPMAX || exp == 0 || low == 0) + low = 0; + else + { + exp -= HALFFRACBITS + 1; + + while (exp > 0 + && low < ((halffractype)1 << HALFFRACBITS)) + { + low <<= 1; + exp--; + } + + if (exp <= 0) + { + halffractype roundmsb, round; + + exp = -exp + 1; + + roundmsb = (1 << (exp - 1)); + round = low & ((roundmsb << 1) - 1); + + low >>= exp; + exp = 0; + + if (round > roundmsb || (round == roundmsb && (low & 1))) + { + low++; + if (low >= ((halffractype)1 << HALFFRACBITS)) + /* We don't shift left, since it has just become the + smallest normal number, whose implicit 1 bit is + now indicated by the non-zero exponent. */ + exp++; + } + } + + low &= ((halffractype)1 << HALFFRACBITS) - 1; + low |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << HALFFRACBITS; + low |= ((fractype) (sign & 1)) << (HALFFRACBITS | EXPBITS); + } + + dst.value_raw = (((fractype) high) << HALFSHIFT) | low; + } +# else dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1); dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS; dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS); +# endif #endif #if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT) @@ -381,9 +438,42 @@ unpack_d (FLO_union_type * src, fp_numbe exp = src->bits.exp; sign = src->bits.sign; #else +# if defined TFLOAT && defined HALFFRACBITS + { + halffractype high, low; + + high = src->value_raw >> HALFSHIFT; + low = src->value_raw & (((fractype)1 << HALFSHIFT) - 1); + + fraction = high & ((((fractype)1) << HALFFRACBITS) - 1); + fraction <<= FRACBITS - HALFFRACBITS; + exp = ((int)(high >> HALFFRACBITS)) & ((1 << EXPBITS) - 1); + sign = ((int)(high >> (((HALFFRACBITS + EXPBITS))))) & 1; + + if (exp != EXPMAX && exp != 0 && low != 0) + { + int lowexp = ((int)(low >> HALFFRACBITS)) & ((1 << EXPBITS) - 1); + int shift; + fractype xlow; + + xlow = low & ((((fractype)1) << HALFFRACBITS) - 1); + if (lowexp) + xlow |= (((halffractype)1) << HALFFRACBITS); + else + lowexp = 1; + shift = (FRACBITS - HALFFRACBITS) - (exp - lowexp); + if (shift > 0) + xlow <<= shift; + else if (shift < 0) + xlow >>= -shift; + fraction += xlow; + } + } +# else fraction = src->value_raw & ((((fractype)1) << FRACBITS) - 1); exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1); sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1; +# endif #endif dst->sign = sign; Index: gcc/config/fp-bit.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/fp-bit.h,v retrieving revision 1.7.18.1 diff -u -p -r1.7.18.1 fp-bit.h --- gcc/config/fp-bit.h 26 Jan 2003 09:30:38 -0000 1.7.18.1 +++ gcc/config/fp-bit.h 26 Jan 2003 10:01:20 -0000 @@ -87,7 +87,7 @@ Boston, MA 02111-1307, USA. */ #endif #endif /* ! FINE_GRAINED_LIBRARIES */ -#if __LDBL_MANT_DIG__ == 113 +#if __LDBL_MANT_DIG__ == 113 || __LDBL_MANT_DIG__ == 106 # define TMODES #endif @@ -150,6 +150,18 @@ typedef unsigned int UTItype __attribute # define FRACHIGH ((TItype)0x8 << 124) # define FRACHIGH2 ((TItype)0xc << 124) # define FRACBITS 112 +# endif + +# if __LDBL_MANT_DIG__ == 106 /* IBM extended (double+double) */ +# define EXPBITS 11 +# define EXPBIAS 1023 +# define EXPMAX (0x7ff) +# define QUIET_NAN ((TItype)0x8 << (48 + 64)) +# define FRACHIGH ((TItype)0x8 << 124) +# define FRACHIGH2 ((TItype)0xc << 124) +# define FRACBITS 105 +# define HALFFRACBITS 52 +# define HALFSHIFT 64 # endif # define pack_d __pack_t --=-=-= Content-length: 289 -- 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 --=-=-=--