]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Nov 2013 11:56:44 +0000 (11:56 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Nov 2013 11:56:44 +0000 (11:56 +0000)
* fold-const.c (fold_binary_loc): Use unsigned rather than signed
HOST_WIDE_INTs when folding (x >> c) << c.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205101 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c

index dbe26236c51f2626e233188d673457e87ea60baa..b83dc021ae5d7076660a90c98a8e23656cbfe03f 100644 (file)
@@ -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>
 
index fc18de56565b4b801712b227f93c2f8806ab08e5..4e1c9a1b3cb81443755edb5ff64853ef8ae3fcd6 100644 (file)
@@ -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;