Commit 5c0f009c by Richard Sandiford Committed by Richard Sandiford

fold-const.c (optimize_bit_field_compare): Use wi:: operations instead of const_binop.

gcc/
	* fold-const.c (optimize_bit_field_compare): Use wi:: operations
	instead of const_binop.
	(fold_binary_loc): Likewise.

From-SVN: r210378
parent 460d1e22
2014-05-13 Richard Sandiford <r.sandiford@uk.ibm.com> 2014-05-13 Richard Sandiford <r.sandiford@uk.ibm.com>
* fold-const.c (optimize_bit_field_compare): Use wi:: operations
instead of const_binop.
(fold_binary_loc): Likewise.
2014-05-13 Richard Sandiford <r.sandiford@uk.ibm.com>
* tree-dfa.h (get_addr_base_and_unit_offset_1): Update array index * tree-dfa.h (get_addr_base_and_unit_offset_1): Update array index
calculation to match get_ref_base_and_extent. calculation to match get_ref_base_and_extent.
......
...@@ -3444,7 +3444,7 @@ optimize_bit_field_compare (location_t loc, enum tree_code code, ...@@ -3444,7 +3444,7 @@ optimize_bit_field_compare (location_t loc, enum tree_code code,
{ {
HOST_WIDE_INT lbitpos, lbitsize, rbitpos, rbitsize, nbitpos, nbitsize; HOST_WIDE_INT lbitpos, lbitsize, rbitpos, rbitsize, nbitpos, nbitsize;
tree type = TREE_TYPE (lhs); tree type = TREE_TYPE (lhs);
tree signed_type, unsigned_type; tree unsigned_type;
int const_p = TREE_CODE (rhs) == INTEGER_CST; int const_p = TREE_CODE (rhs) == INTEGER_CST;
enum machine_mode lmode, rmode, nmode; enum machine_mode lmode, rmode, nmode;
int lunsignedp, runsignedp; int lunsignedp, runsignedp;
...@@ -3489,7 +3489,6 @@ optimize_bit_field_compare (location_t loc, enum tree_code code, ...@@ -3489,7 +3489,6 @@ optimize_bit_field_compare (location_t loc, enum tree_code code,
/* Set signed and unsigned types of the precision of this mode for the /* Set signed and unsigned types of the precision of this mode for the
shifts below. */ shifts below. */
signed_type = lang_hooks.types.type_for_mode (nmode, 0);
unsigned_type = lang_hooks.types.type_for_mode (nmode, 1); unsigned_type = lang_hooks.types.type_for_mode (nmode, 1);
/* Compute the bit position and size for the new reference and our offset /* Compute the bit position and size for the new reference and our offset
...@@ -3538,10 +3537,7 @@ optimize_bit_field_compare (location_t loc, enum tree_code code, ...@@ -3538,10 +3537,7 @@ optimize_bit_field_compare (location_t loc, enum tree_code code,
if (lunsignedp) if (lunsignedp)
{ {
if (! integer_zerop (const_binop (RSHIFT_EXPR, if (wi::lrshift (rhs, lbitsize) != 0)
fold_convert_loc (loc,
unsigned_type, rhs),
size_int (lbitsize))))
{ {
warning (0, "comparison is always %d due to width of bit-field", warning (0, "comparison is always %d due to width of bit-field",
code == NE_EXPR); code == NE_EXPR);
...@@ -3550,10 +3546,8 @@ optimize_bit_field_compare (location_t loc, enum tree_code code, ...@@ -3550,10 +3546,8 @@ optimize_bit_field_compare (location_t loc, enum tree_code code,
} }
else else
{ {
tree tem = const_binop (RSHIFT_EXPR, wide_int tem = wi::arshift (rhs, lbitsize - 1);
fold_convert_loc (loc, signed_type, rhs), if (tem != 0 && tem != -1)
size_int (lbitsize - 1));
if (! integer_zerop (tem) && ! integer_all_onesp (tem))
{ {
warning (0, "comparison is always %d due to width of bit-field", warning (0, "comparison is always %d due to width of bit-field",
code == NE_EXPR); code == NE_EXPR);
...@@ -10356,9 +10350,8 @@ fold_binary_loc (location_t loc, ...@@ -10356,9 +10350,8 @@ fold_binary_loc (location_t loc,
&& TREE_CODE (arg1) == BIT_AND_EXPR && TREE_CODE (arg1) == BIT_AND_EXPR
&& TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
&& TREE_CODE (TREE_OPERAND (arg1, 1)) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg1, 1)) == INTEGER_CST
&& integer_zerop (const_binop (BIT_AND_EXPR, && wi::bit_and (TREE_OPERAND (arg0, 1),
TREE_OPERAND (arg0, 1), TREE_OPERAND (arg1, 1)) == 0)
TREE_OPERAND (arg1, 1))))
{ {
code = BIT_IOR_EXPR; code = BIT_IOR_EXPR;
goto bit_ior; goto bit_ior;
...@@ -11478,9 +11471,8 @@ fold_binary_loc (location_t loc, ...@@ -11478,9 +11471,8 @@ fold_binary_loc (location_t loc,
&& TREE_CODE (arg1) == BIT_AND_EXPR && TREE_CODE (arg1) == BIT_AND_EXPR
&& TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
&& TREE_CODE (TREE_OPERAND (arg1, 1)) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg1, 1)) == INTEGER_CST
&& integer_zerop (const_binop (BIT_AND_EXPR, && wi::bit_and (TREE_OPERAND (arg0, 1),
TREE_OPERAND (arg0, 1), TREE_OPERAND (arg1, 1)) == 0)
TREE_OPERAND (arg1, 1))))
{ {
code = BIT_IOR_EXPR; code = BIT_IOR_EXPR;
goto bit_ior; goto bit_ior;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment