This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: PR other/30530: dfp.c assumes DPD encoding
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Janis Johnson <janis187 at us dot ibm dot com>
- Cc: bje at au1 dot ibm dot com, gcc-patches at gcc dot gnu dot org
- Date: Sun, 21 Jan 2007 13:55:12 -0800
- Subject: PATCH: PR other/30530: dfp.c assumes DPD encoding
Hi Ben,
Does this patch look OK?
Thanks.
H.J.
----
2007-01-21 H.J. Lu <hongjiu.lu@intel.com>
PR other/30530
* dfp.c (decimal_real_arithmetic): Use decimal128Sign and
decimal128SetSign to flip/clear the sign bit in decimal128.
(decimal_real_maxval): Set decimal128SetSign to set the sign
bit in decimal128.
--- gcc/dfp.c.dpd 2006-09-27 22:38:25.000000000 -0700
+++ gcc/dfp.c 2007-01-21 13:47:38.000000000 -0800
@@ -656,11 +656,11 @@ decimal_real_arithmetic (REAL_VALUE_TYPE
case NEGATE_EXPR:
{
- decimal128 *d128;
+ unsigned int sign;
*r = *op0;
- d128 = (decimal128 *) r->sig;
- /* Flip high bit. */
- d128->bytes[0] ^= 1 << 7;
+ sign = decimal128Sign ((decimal128 *) r->sig);
+ /* Flip sign bit. */
+ decimal128SetSign ((decimal128 *) r->sig, !sign);
/* Keep sign field in sync. */
r->sign ^= 1;
}
@@ -668,11 +668,9 @@ decimal_real_arithmetic (REAL_VALUE_TYPE
case ABS_EXPR:
{
- decimal128 *d128;
*r = *op0;
- d128 = (decimal128 *) r->sig;
- /* Clear high bit. */
- d128->bytes[0] &= 0x7f;
+ /* Clear sign bit. */
+ decimal128SetSign ((decimal128 *) r->sig, 0);
/* Keep sign field in sync. */
r->sign = 0;
}
@@ -712,5 +710,5 @@ decimal_real_maxval (REAL_VALUE_TYPE *r,
decimal_real_from_string (r, max);
if (sign)
- r->sig[0] |= 0x80000000;
+ decimal128SetSign ((decimal128 *) r->sig, 1);
}