From: Richard Kenner Date: Fri, 9 Apr 1993 01:39:46 +0000 (-0400) Subject: (force_to_mode... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f67850266f1c06c34c97b42d011a47a0920d5e3c;p=gcc.git (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 --- diff --git a/gcc/combine.c b/gcc/combine.c index 6993356eb07..11dec08d7cb 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))