diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1993-04-08 21:39:46 -0400 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1993-04-08 21:39:46 -0400 |
commit | f67850266f1c06c34c97b42d011a47a0920d5e3c (patch) | |
tree | 57c4400ddf3a7f5fbe80f8afabd16e8b915689ce | |
parent | 5bf6e3bd1e9e653d0857f5a480df9797d89580be (diff) | |
download | gcc-f67850266f1c06c34c97b42d011a47a0920d5e3c.zip gcc-f67850266f1c06c34c97b42d011a47a0920d5e3c.tar.gz gcc-f67850266f1c06c34c97b42d011a47a0920d5e3c.tar.bz2 |
(force_to_mode...
(force_to_mode, case xSHIFT): Don't narrow the mode unless we can be
sure that the shift count is smaller than the size of the mode.
From-SVN: r4050
-rw-r--r-- | gcc/combine.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/combine.c b/gcc/combine.c index 6993356..11dec08 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -5342,9 +5342,21 @@ force_to_mode (x, mode, bits, reg) case ASHIFT: case LSHIFT: /* For left shifts, do the same, but just for the first operand. - If the shift count is a constant, we need even fewer bits of the - first operand. */ - + However, we cannot do anything with shifts where we cannot + guarantee that the counts are smaller than the size of the mode + because such a count will have a different meaning in a + wider mode. + + If we can narrow the shift and know the count, we need even fewer + bits of the first operand. */ + + if (! (GET_CODE (XEXP (x, 1)) == CONST_INT + && INTVAL (XEXP (x, 1)) < GET_MODE_BITSIZE (mode)) + && ! (GET_MODE (XEXP (x, 1)) != VOIDmode + && (nonzero_bits (XEXP (x, 1), GET_MODE (XEXP (x, 1))) + < (unsigned) GET_MODE_BITSIZE (mode)))) + break; + if (GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) < bits) bits -= INTVAL (XEXP (x, 1)); @@ -5364,8 +5376,8 @@ force_to_mode (x, mode, bits, reg) case LSHIFTRT: /* Here we can only do something if the shift count is a constant and - the count plus BITS is no larger than the width of MODE, we can do - the shift in MODE. */ + the count plus BITS is no larger than the width of MODE. In that + case, we can do the shift in MODE. */ if (GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) + bits <= GET_MODE_BITSIZE (mode)) |