aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-07-26 22:16:16 +0000
committerRichard Stallman <rms@gnu.org>1993-07-26 22:16:16 +0000
commit437b3c097dbc0157e978e2e31c672542cf72d564 (patch)
tree5480a9655d364207cc743b920dacbd0dc0dd72de
parentfa1a4543fddd8de5f327b774e9cb71e62d66ee1d (diff)
downloadgcc-437b3c097dbc0157e978e2e31c672542cf72d564.zip
gcc-437b3c097dbc0157e978e2e31c672542cf72d564.tar.gz
gcc-437b3c097dbc0157e978e2e31c672542cf72d564.tar.bz2
(simplify_shift_const): Inhibit hacks based on
num_sign_bit_copies if shift_mode differs from the mode of varop. From-SVN: r4994
-rw-r--r--gcc/combine.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index fa18f29..b821af2 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -7122,25 +7122,31 @@ simplify_shift_const (x, code, result_mode, varop, count)
else if (count < 0)
abort ();
- /* 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;
- }
+ /* 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)))
+ {
+ 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.