This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/30704] [4.2/4.3 Regression] Incorrect constant generation for long long
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Mar 2007 23:18:52 -0000
- Subject: [Bug middle-end/30704] [4.2/4.3 Regression] Incorrect constant generation for long long
- References: <bug-30704-276@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from pinskia at gcc dot gnu dot org 2007-03-12 23:18 -------
Here is my new patch:
Index: ../../gcc/fold-const.c
===================================================================
--- ../../gcc/fold-const.c (revision 122864)
+++ ../../gcc/fold-const.c (working copy)
@@ -7357,6 +7357,7 @@ native_interpret_real (tree type, unsign
up to 192 bits. */
REAL_VALUE_TYPE r;
long tmp[6];
+ long tmp1[6];
total_bytes = GET_MODE_SIZE (TYPE_MODE (type));
if (total_bytes > len || total_bytes > 24)
@@ -7367,6 +7368,7 @@ native_interpret_real (tree type, unsign
for (byte = 0; byte < total_bytes; byte++)
{
int bitpos = byte * BITS_PER_UNIT;
+ int bytepos;
if (total_bytes > UNITS_PER_WORD)
{
word = byte / UNITS_PER_WORD;
@@ -7381,11 +7383,18 @@ native_interpret_real (tree type, unsign
else
offset = BYTES_BIG_ENDIAN ? (total_bytes - 1) - byte : byte;
value = ptr[offset];
+ bytepos = FLOAT_WORDS_BIG_ENDIAN ? total_bytes / 4 - bitpos / 32 - 1 :
bitpos / 32;
- tmp[bitpos / 32] |= (unsigned long)value << (bitpos & 31);
+ tmp[bytepos] |= (unsigned long)value << (bitpos & 31);
+ printf("%ld %ld [%d,%d]\n", tmp[0], tmp[1], bytepos, bitpos);
}
real_from_target (&r, tmp, mode);
+ real_to_target (tmp1, &r, mode);
+ /* If the encoded real is going to decode differently, then reject the
constant
+ conversion. */
+ if (memcmp (tmp, tmp1, total_bytes) != 0)
+ return NULL;
return build_real (type, r);
}
I am not 100 % sure this is correct but we get the correct constant now for
this one.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30704