GDB/libiberty support for IBM long double

Andreas Schwab schwab@suse.de
Fri Dec 28 12:29:00 GMT 2007


Luis Machado <luisgpm@linux.vnet.ibm.com> writes:

> Removing this condition fixes the problem, but i'm not sure this is 100%
> safe as this condition must have a purpose.
>
> Any ideas?

That part of the function can be simplified quite a bit.  For example,
NaNs and infinities are already handled at this point, thus
special_exponent can only be true when the biased exponent is zero.

--- libiberty/floatformat.c.~1.25.~	2007-11-16 11:17:29.000000000 +0100
+++ libiberty/floatformat.c	2007-12-28 11:26:21.000000000 +0100
@@ -487,9 +487,9 @@ floatformat_to_double (const struct floa
   mant_off = fmt->man_start;
   dto = 0.0;
 
-  special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan;
+  special_exponent = exponent == 0;
 
-  /* Don't bias zero's, denorms or NaNs.  */
+  /* Don't bias zeros or denorms.  */
   if (!special_exponent)
     exponent -= fmt->exp_bias;
 
@@ -516,16 +516,15 @@ floatformat_to_double (const struct floa
 
       /* Handle denormalized numbers.  FIXME: What should we do for
 	 non-IEEE formats?  */
-      if (special_exponent && exponent == 0 && mant != 0)
-	dto += ldexp ((double)mant,
+      if (special_exponent)
+	dto += ldexp ((double) mant,
 		      (- fmt->exp_bias
 		       - mant_bits
 		       - (mant_off - fmt->man_start)
 		       + 1));
       else
-	dto += ldexp ((double)mant, exponent - mant_bits);
-      if (exponent != 0)
-	exponent -= mant_bits;
+	dto += ldexp ((double) mant, exponent - mant_bits);
+      exponent -= mant_bits;
       mant_off += mant_bits;
       mant_bits_left -= mant_bits;
     }

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Gdb-patches mailing list