On Wed, Oct 10, 2012 at 8:39 AM, Jakub Jelinek <ja...@redhat.com> wrote: > Hi! > > On 32-bit HWI warning there is a warning about signed (INTVAL) vs. unsigned > ({,op_}precision) comparison (on 64-bit HWI that doesn't trigger, as > INTVAL is 64-bit signed long, while precision is 32-bit unsigned). > This patch fixes the warning and makes sure we don't try to optimize > shifts by negative count. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Ok. Thanks, Richard. > 2012-10-10 Jakub Jelinek <ja...@redhat.com> > > PR middle-end/54862 > * simplify-rtx.c (simplify_truncation): Compare UINTVAL instead of > INTVAL of second argument with precision resp. op_precision. > > --- gcc/simplify-rtx.c.jj 2012-10-08 21:37:33.000000000 +0200 > +++ gcc/simplify-rtx.c 2012-10-09 13:48:24.269969321 +0200 > @@ -668,7 +668,7 @@ simplify_truncation (enum machine_mode m > && CONST_INT_P (XEXP (op, 1)) > && GET_CODE (XEXP (op, 0)) == SIGN_EXTEND > && GET_MODE (XEXP (XEXP (op, 0), 0)) == mode > - && INTVAL (XEXP (op, 1)) < precision) > + && UINTVAL (XEXP (op, 1)) < precision) > return simplify_gen_binary (ASHIFTRT, mode, > XEXP (XEXP (op, 0), 0), XEXP (op, 1)); > > @@ -680,7 +680,7 @@ simplify_truncation (enum machine_mode m > && CONST_INT_P (XEXP (op, 1)) > && GET_CODE (XEXP (op, 0)) == ZERO_EXTEND > && GET_MODE (XEXP (XEXP (op, 0), 0)) == mode > - && INTVAL (XEXP (op, 1)) < precision) > + && UINTVAL (XEXP (op, 1)) < precision) > return simplify_gen_binary (LSHIFTRT, mode, > XEXP (XEXP (op, 0), 0), XEXP (op, 1)); > > @@ -692,7 +692,7 @@ simplify_truncation (enum machine_mode m > && (GET_CODE (XEXP (op, 0)) == ZERO_EXTEND > || GET_CODE (XEXP (op, 0)) == SIGN_EXTEND) > && GET_MODE (XEXP (XEXP (op, 0), 0)) == mode > - && INTVAL (XEXP (op, 1)) < precision) > + && UINTVAL (XEXP (op, 1)) < precision) > return simplify_gen_binary (ASHIFT, mode, > XEXP (XEXP (op, 0), 0), XEXP (op, 1)); > > @@ -705,8 +705,7 @@ simplify_truncation (enum machine_mode m > && 2 * precision <= op_precision > && CONST_INT_P (XEXP (op, 1)) > && (INTVAL (XEXP (op, 1)) & (precision - 1)) == 0 > - && INTVAL (XEXP (op, 1)) >= 0 > - && INTVAL (XEXP (op, 1)) < op_precision) > + && UINTVAL (XEXP (op, 1)) < op_precision) > { > int byte = subreg_lowpart_offset (mode, op_mode); > int shifted_bytes = INTVAL (XEXP (op, 1)) / BITS_PER_UNIT; > > Jakub