From f67850266f1c06c34c97b42d011a47a0920d5e3c Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Thu, 8 Apr 1993 21:39:46 -0400 Subject: [PATCH] (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 --- gcc/combine.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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)) -- 2.30.2