aboutsummaryrefslogtreecommitdiff
path: root/gcc/cse.c
diff options
context:
space:
mode:
authorTorbjorn Granlund <tege@gnu.org>1995-04-03 23:19:02 +0000
committerTorbjorn Granlund <tege@gnu.org>1995-04-03 23:19:02 +0000
commitad89d6f68a89f4370430e37a22c60dc62c946623 (patch)
treecf19dc2e9813ce9aa65a7242b50319789111bb79 /gcc/cse.c
parent2e14370ed42be496fb7a5f2d803824a01a646abe (diff)
downloadgcc-ad89d6f68a89f4370430e37a22c60dc62c946623.zip
gcc-ad89d6f68a89f4370430e37a22c60dc62c946623.tar.gz
gcc-ad89d6f68a89f4370430e37a22c60dc62c946623.tar.bz2
(simplify_unary_operation): Sign-extend constants when they have the most significant bit set for the target.
(simplify_unary_operation): Sign-extend constants when they have the most significant bit set for the target. (simplify_binary_operation): Likewise. From-SVN: r9309
Diffstat (limited to 'gcc/cse.c')
-rw-r--r--gcc/cse.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cse.c b/gcc/cse.c
index 7a0aba8..b9da905 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -3266,6 +3266,19 @@ simplify_unary_operation (code, mode, op, op_mode)
!= ((HOST_WIDE_INT) (-1) << (width - 1))))
val &= ((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
+ && (val & ((HOST_WIDE_INT) 1 << (width - 1))))
+ val |= ((HOST_WIDE_INT) (-1) << width);
+
return GEN_INT (val);
}
#endif
@@ -4126,6 +4139,19 @@ simplify_binary_operation (code, mode, op0, op1)
!= ((HOST_WIDE_INT) (-1) << (width - 1))))
val &= ((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
+ && (val & ((HOST_WIDE_INT) 1 << (width - 1))))
+ val |= ((HOST_WIDE_INT) (-1) << width);
+
return GEN_INT (val);
}