From: Marek Polacek Date: Mon, 1 Sep 2014 09:18:43 +0000 (+0000) Subject: re PR middle-end/61903 (signed integer overflow in expmed.c store_fixed_bit_filed_1) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e507a43338b75714233a271186baa4c68bf50e64;p=gcc.git re PR middle-end/61903 (signed integer overflow in expmed.c store_fixed_bit_filed_1) PR middle-end/61903 * expmed.c (store_fixed_bit_field_1): Shift UHWI 1 instead of HWI 1. Change the type of V to unsigned HOST_WIDE_INT. From-SVN: r214781 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 19f7f7935d6..ec0e6c44fd0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-09-01 Marek Polacek + + PR middle-end/61903 + * expmed.c (store_fixed_bit_field_1): Shift UHWI 1 instead of HWI 1. + Change the type of V to unsigned HOST_WIDE_INT. + 2014-09-01 Thomas Preud'homme * tree-ssa-math-opts.c (struct symbolic_number): Clarify comment about diff --git a/gcc/expmed.c b/gcc/expmed.c index 1eb712e84ba..82afd7fee50 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -1057,16 +1057,17 @@ store_fixed_bit_field_1 (rtx op0, unsigned HOST_WIDE_INT bitsize, if (CONST_INT_P (value)) { - HOST_WIDE_INT v = INTVAL (value); + unsigned HOST_WIDE_INT v = UINTVAL (value); if (bitsize < HOST_BITS_PER_WIDE_INT) - v &= ((HOST_WIDE_INT) 1 << bitsize) - 1; + v &= ((unsigned HOST_WIDE_INT) 1 << bitsize) - 1; if (v == 0) all_zero = 1; else if ((bitsize < HOST_BITS_PER_WIDE_INT - && v == ((HOST_WIDE_INT) 1 << bitsize) - 1) - || (bitsize == HOST_BITS_PER_WIDE_INT && v == -1)) + && v == ((unsigned HOST_WIDE_INT) 1 << bitsize) - 1) + || (bitsize == HOST_BITS_PER_WIDE_INT + && v == (unsigned HOST_WIDE_INT) -1)) all_one = 1; value = lshift_value (mode, v, bitnum);