aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Wilson <wilson@gcc.gnu.org>1994-04-11 10:22:33 -0700
committerJim Wilson <wilson@gcc.gnu.org>1994-04-11 10:22:33 -0700
commit2ba3a0eceffae2f34927301ae596ca1befcbbff9 (patch)
treecc7e9146578210216d453c72d5ff65467e36a263
parent7373d92d2f7827d896b80e54c4bf9bd8ef6cf978 (diff)
downloadgcc-2ba3a0eceffae2f34927301ae596ca1befcbbff9.zip
gcc-2ba3a0eceffae2f34927301ae596ca1befcbbff9.tar.gz
gcc-2ba3a0eceffae2f34927301ae596ca1befcbbff9.tar.bz2
(immed_double_const): Sign-extend constants when they
have the most significant bit set for the target. From-SVN: r7027
-rw-r--r--gcc/varasm.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 17117c0..a09852a 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -1785,6 +1785,19 @@ immed_double_const (i0, i1, mode)
/* We cannot represent this value as a constant. */
abort ();
+ /* If this would be an entire word for the target, but is not for
+ the host, then sign-extend on the host so that the number will look
+ the same way on the host that it would on the target.
+
+ For example, when building a 64 bit alpha hosted 32 bit sparc
+ targeted compiler, then we want the 32 bit unsigned value -1 to be
+ represented as a 64 bit value -1, and not as 0x00000000ffffffff.
+ The later confuses the sparc backend. */
+
+ if (BITS_PER_WORD < HOST_BITS_PER_WIDE_INT && BITS_PER_WORD == width
+ && (i0 & ((HOST_WIDE_INT) 1 << (width - 1))))
+ i0 |= ((HOST_WIDE_INT) (-1) << width);
+
/* If MODE fits within HOST_BITS_PER_WIDE_INT, always use a CONST_INT.
??? Strictly speaking, this is wrong if we create a CONST_INT