aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1993-08-08 17:31:39 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1993-08-08 17:31:39 -0400
commit312def2eda47dd591c50f9bf9959fc3129e275e0 (patch)
tree183cc19aba5df130a788a5bd88d0675d808837a5
parent00aae7b152f77c0aa1e0bd9ac2001635ca9c7c95 (diff)
downloadgcc-312def2eda47dd591c50f9bf9959fc3129e275e0.zip
gcc-312def2eda47dd591c50f9bf9959fc3129e275e0.tar.gz
gcc-312def2eda47dd591c50f9bf9959fc3129e275e0.tar.bz2
(num_sign_bit_copies): Properly handle case when MODE is narrower than that of X.
(num_sign_bit_copies): Properly handle case when MODE is narrower than that of X. (simplify_shift_const): Remove change of July 26. From-SVN: r5110
-rw-r--r--gcc/combine.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index 1362dbc..ffc92f8 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6687,6 +6687,11 @@ num_sign_bit_copies (x, mode)
bitwidth = GET_MODE_BITSIZE (mode);
+ /* For a smaller object, just ignore the high bits. */
+ if (bitwidth < GET_MODE_BITSIZE (GET_MODE (x)))
+ return MAX (1, (num_sign_bit_copies (x, GET_MODE (x))
+ - (GET_MODE_BITSIZE (GET_MODE (x)) - bitwidth)));
+
switch (code)
{
case REG:
@@ -7181,31 +7186,25 @@ simplify_shift_const (x, code, result_mode, varop, count)
else if (count < 0)
abort ();
- /* If we have replaced VAROP with something wider
- (such as, the SUBREG_REG), then this won't work;
- num_sign_bit_copies will give the wrong answer in that case. */
- if (shift_mode == GET_MODE (varop))
+ /* An arithmetic right shift of a quantity known to be -1 or 0
+ is a no-op. */
+ if (code == ASHIFTRT
+ && (num_sign_bit_copies (varop, shift_mode)
+ == GET_MODE_BITSIZE (shift_mode)))
{
- /* An arithmetic right shift of a quantity known to be -1 or 0
- is a no-op. */
- if (code == ASHIFTRT
- && (num_sign_bit_copies (varop, shift_mode)
- == GET_MODE_BITSIZE (shift_mode)))
- {
- count = 0;
- break;
- }
+ count = 0;
+ break;
+ }
- /* If we are doing an arithmetic right shift and discarding all but
- the sign bit copies, this is equivalent to doing a shift by the
- bitsize minus one. Convert it into that shift because it will often
- allow other simplifications. */
+ /* If we are doing an arithmetic right shift and discarding all but
+ the sign bit copies, this is equivalent to doing a shift by the
+ bitsize minus one. Convert it into that shift because it will often
+ allow other simplifications. */
- if (code == ASHIFTRT
- && (count + num_sign_bit_copies (varop, shift_mode)
- >= GET_MODE_BITSIZE (shift_mode)))
- count = GET_MODE_BITSIZE (shift_mode) - 1;
- }
+ if (code == ASHIFTRT
+ && (count + num_sign_bit_copies (varop, shift_mode)
+ >= GET_MODE_BITSIZE (shift_mode)))
+ count = GET_MODE_BITSIZE (shift_mode) - 1;
/* We simplify the tests below and elsewhere by converting
ASHIFTRT to LSHIFTRT if we know the sign bit is clear.