This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: rs6000 LDBL_MAX converts to infinity


On Thu, Mar 04, 2004 at 06:38:31PM +1030, Alan Modra wrote:
> 	* real.c (encode_ibm_extended): Don't bother rounding low double.

I blew it.  There's another reason to call round_for_format here, and
that's to handle denormals.  Without the round_for_format call we
can pass encode_ieee_double an exponent that's too negative, and
it will merrily wrap around to a large positive exponent.
A testcase is a value like __LDBL_MIN__ + __LDBL_DENORM_MIN__.

This reverts my previous patch and adds a comment explaining
why round_for_format is called.

	* real.c (encode_ibm_extended): Do round low word.

Applying mainline.  Mark, this needs to go on the branch too please.

Index: gcc/real.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/real.c,v
retrieving revision 1.139
diff -u -p -r1.139 real.c
--- gcc/real.c	4 Mar 2004 10:23:20 -0000	1.139
+++ gcc/real.c	11 Mar 2004 13:28:12 -0000
@@ -3248,9 +3248,8 @@ encode_ibm_extended (const struct real_f
   if (u.class == rvc_normal)
     {
       do_add (&v, &normr, &u, 1);
-      /* The low double won't need rounding, since we round to a 106 bit
-	 mantissa before calling this function, and we've just
-	 subtracted off the top 54 bits.  (53+1 because u is rounded.)  */
+      /* Call round_for_format since we might need to denormalize.  */
+      round_for_format (base_fmt, &v);
       encode_ieee_double (base_fmt, &buf[2], &v);
     }
   else

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]