diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dbe26236c51..b83dc021ae5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2013-11-20 Richard Sandiford + + * fold-const.c (fold_binary_loc): Use unsigned rather than signed + HOST_WIDE_INTs when folding (x >> c) << c. + 2013-11-20 Andreas Krebbel Dominik Vogt diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fc18de56565..4e1c9a1b3cb 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12679,13 +12679,13 @@ fold_binary_loc (location_t loc, if (((code == LSHIFT_EXPR && TREE_CODE (arg0) == RSHIFT_EXPR) || (TYPE_UNSIGNED (type) && code == RSHIFT_EXPR && TREE_CODE (arg0) == LSHIFT_EXPR)) - && tree_fits_shwi_p (arg1) - && TREE_INT_CST_LOW (arg1) < prec - && tree_fits_shwi_p (TREE_OPERAND (arg0, 1)) - && TREE_INT_CST_LOW (TREE_OPERAND (arg0, 1)) < prec) + && tree_fits_uhwi_p (arg1) + && tree_to_uhwi (arg1) < prec + && tree_fits_uhwi_p (TREE_OPERAND (arg0, 1)) + && tree_to_uhwi (TREE_OPERAND (arg0, 1)) < prec) { - HOST_WIDE_INT low0 = TREE_INT_CST_LOW (TREE_OPERAND (arg0, 1)); - HOST_WIDE_INT low1 = TREE_INT_CST_LOW (arg1); + HOST_WIDE_INT low0 = tree_to_uhwi (TREE_OPERAND (arg0, 1)); + HOST_WIDE_INT low1 = tree_to_uhwi (arg1); tree lshift; tree arg00;