fold-const.c (fold_binary_loc): Use unsigned rather than signed HOST_WIDE_INTs when folding (x >> c) << c.

gcc/
	* fold-const.c (fold_binary_loc): Use unsigned rather than signed
	HOST_WIDE_INTs when folding (x >> c) << c.

From-SVN: r205101
This commit is contained in:
Richard Sandiford 2013-11-20 11:56:44 +00:00 committed by Richard Sandiford
parent 6b3b8c2754
commit 5193531872
2 changed files with 11 additions and 6 deletions

View 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>

View 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;