From: aoliva Date: Tue, 13 Feb 2001 06:39:45 +0000 (+0000) Subject: * explow.c (trunc_int_for_mode): Sign-extend value to mode. X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=679dcb763617b8fecd5eb7c28cd1efcfea88135c;p=pf3gnuchains%2Fgcc-fork.git * explow.c (trunc_int_for_mode): Sign-extend value to mode. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39615 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a45377684e7..8761c12ec50 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2001-02-13 Alexandre Oliva + + * explow.c (trunc_int_for_mode): Sign-extend value to mode. + 2001-02-12 Geoffrey Keating * config/rs6000/sysv4.h (MASK_NO_BITFIELD_WORD): New macro. diff --git a/gcc/explow.c b/gcc/explow.c index b7c0bb9f6d9..719421f6cd6 100644 --- a/gcc/explow.c +++ b/gcc/explow.c @@ -56,28 +56,16 @@ trunc_int_for_mode (c, mode) if (mode == BImode) return c & 1 ? STORE_FLAG_VALUE : 0; - /* We clear out all bits that don't belong in MODE, unless they and our - sign bit are all one. So we get either a reasonable negative - value or a reasonable unsigned value. */ - - if (width < HOST_BITS_PER_WIDE_INT - && ((c & ((HOST_WIDE_INT) (-1) << (width - 1))) - != ((HOST_WIDE_INT) (-1) << (width - 1)))) - c &= ((HOST_WIDE_INT) 1 << width) - 1; - - /* 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 - && (c & ((HOST_WIDE_INT) 1 << (width - 1)))) - c |= ((HOST_WIDE_INT) (-1) << width); + /* Sign-extend for the requested mode. */ + + if (width < HOST_BITS_PER_WIDE_INT) + { + HOST_WIDE_INT sign = 1; + sign <<= width - 1; + c &= (sign << 1) - 1; + c ^= sign; + c -= sign; + } return c; }