aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c12
2 files changed, 11 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dbe2623..b83dc02 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2013-11-20 Richard Sandiford <rdsandiford@googlemail.com>
+
+ * fold-const.c (fold_binary_loc): Use unsigned rather than signed
+ HOST_WIDE_INTs when folding (x >> c) << c.
+
2013-11-20 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
Dominik Vogt <vogt@linux.vnet.ibm.com>
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index fc18de5..4e1c9a1 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;