From d4c52634cef1d2e86c3b460a1128e3301ecf769d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 14 May 2013 14:06:27 +0200 Subject: [PATCH] re PR bootstrap/57266 (comparison between signed and unsigned integer expressions in fold_binary_loc breaks m68k bootstrap) 2013-05-14 Marc Glisse PR bootstrap/57266 * fold-const.c (fold_binary_loc) : Use an unsigned variable for the shift amount. Check that we shift by non-negative amounts. From-SVN: r198880 --- gcc/ChangeLog | 7 +++++++ gcc/fold-const.c | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 15cafbb..76ab15d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2013-05-14 Marc Glisse + + PR bootstrap/57266 + * fold-const.c (fold_binary_loc) : Use an unsigned + variable for the shift amount. Check that we shift by non-negative + amounts. + 2013-05-14 Chung-Lin Tang PR target/42017 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index cbd3445..5d6bbbb 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12423,13 +12423,13 @@ fold_binary_loc (location_t loc, prec = element_precision (type); /* Turn (a OP c1) OP c2 into a OP (c1+c2). */ - if (TREE_CODE (op0) == code && host_integerp (arg1, false) + if (TREE_CODE (op0) == code && host_integerp (arg1, true) && TREE_INT_CST_LOW (arg1) < prec - && host_integerp (TREE_OPERAND (arg0, 1), false) + && host_integerp (TREE_OPERAND (arg0, 1), true) && TREE_INT_CST_LOW (TREE_OPERAND (arg0, 1)) < prec) { - HOST_WIDE_INT low = (TREE_INT_CST_LOW (TREE_OPERAND (arg0, 1)) - + TREE_INT_CST_LOW (arg1)); + unsigned int low = (TREE_INT_CST_LOW (TREE_OPERAND (arg0, 1)) + + TREE_INT_CST_LOW (arg1)); /* Deal with a OP (c1 + c2) being undefined but (a OP c1) OP c2 being well defined. */ -- 2.7.4