aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2013-05-06 10:23:02 +0200
committerThomas Schwinge <tschwinge@gcc.gnu.org>2013-05-06 10:23:02 +0200
commite5123d087ed24066c03c97c92a15d255c8d318dd (patch)
treee05b2f2fcb768975dd4c02f9879f967e78f0832d
parent701e2f0a76da581d75fa3adac925d58aff7a1290 (diff)
downloadgcc-e5123d087ed24066c03c97c92a15d255c8d318dd.zip
gcc-e5123d087ed24066c03c97c92a15d255c8d318dd.tar.gz
gcc-e5123d087ed24066c03c97c92a15d255c8d318dd.tar.bz2
fp-bit.c (unpack_d, pack_d): Properly preserve and restore a NaN's payload.
libgcc/ * fp-bit.c (unpack_d, pack_d): Properly preserve and restore a NaN's payload. From-SVN: r198622
-rw-r--r--libgcc/ChangeLog3
-rw-r--r--libgcc/fp-bit.c15
-rw-r--r--libgcc/fp-bit.h2
3 files changed, 16 insertions, 4 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index e4e0d57..c874a84 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,5 +1,8 @@
2013-05-06 Thomas Schwinge <thomas@codesourcery.com>
+ * fp-bit.c (unpack_d, pack_d): Properly preserve and restore a
+ NaN's payload.
+
* fp-bit.h [FLOAT] (QUIET_NAN): Correct value.
2013-04-25 Alan Modra <amodra@gmail.com>
diff --git a/libgcc/fp-bit.c b/libgcc/fp-bit.c
index 60f2338..9b0c194 100644
--- a/libgcc/fp-bit.c
+++ b/libgcc/fp-bit.c
@@ -213,11 +213,18 @@ pack_d (const fp_number_type *src)
else if (isnan (src))
{
exp = EXPMAX;
+ /* Restore the NaN's payload. */
+ fraction >>= NGARDS;
+ fraction &= QUIET_NAN - 1;
if (src->class == CLASS_QNAN || 1)
{
#ifdef QUIET_NAN_NEGATED
- fraction |= QUIET_NAN - 1;
+ /* The quiet/signaling bit remains unset. */
+ /* Make sure the fraction has a non-zero value. */
+ if (fraction == 0)
+ fraction |= QUIET_NAN - 1;
#else
+ /* Set the quiet/signaling bit. */
fraction |= QUIET_NAN;
#endif
}
@@ -573,8 +580,10 @@ unpack_d (FLO_union_type * src, fp_number_type * dst)
{
dst->class = CLASS_SNAN;
}
- /* Keep the fraction part as the nan number */
- dst->fraction.ll = fraction;
+ /* Now that we know which kind of NaN we got, discard the
+ quiet/signaling bit, but do preserve the NaN payload. */
+ fraction &= ~QUIET_NAN;
+ dst->fraction.ll = fraction << NGARDS;
}
}
else
diff --git a/libgcc/fp-bit.h b/libgcc/fp-bit.h
index 2ac504a..b6fe9f7 100644
--- a/libgcc/fp-bit.h
+++ b/libgcc/fp-bit.h
@@ -297,7 +297,7 @@ typedef unsigned int UTItype __attribute__ ((mode (TI)));
/* numeric parameters */
/* F_D_BITOFF is the number of bits offset between the MSB of the mantissa
of a float and of a double. Assumes there are only two float types.
- (double::FRAC_BITS+double::NGARDS-(float::FRAC_BITS-float::NGARDS))
+ (double::FRAC_BITS+double::NGARDS-(float::FRAC_BITS+float::NGARDS))
*/
#define F_D_BITOFF (52+8-(23+7))