From 2ba3a0eceffae2f34927301ae596ca1befcbbff9 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Mon, 11 Apr 1994 10:22:33 -0700 Subject: [PATCH] (immed_double_const): Sign-extend constants when they have the most significant bit set for the target. From-SVN: r7027 --- gcc/varasm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/varasm.c b/gcc/varasm.c index 17117c0f8b4..a09852acc93 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 -- 2.30.2