match.pd: Implement more patterns that simplify to a single value.

2014-10-30  Richard Biener  <rguenther@suse.de>

	* match.pd: Implement more patterns that simplify to a single value.
	* fold-const.c (fold_binary_loc): Remove them here.
	* tree-ssa-forwprop.c (simplify_bitwise_binary): Likewise.
	(fwprop_ssa_val): Remove restriction on single uses.

From-SVN: r216933
This commit is contained in:
Richard Biener 2014-10-30 13:13:35 +00:00 committed by Richard Biener
parent 6327f612fd
commit 36a60e48f4
4 changed files with 27 additions and 27 deletions

View File

@ -1,3 +1,10 @@
2014-10-30 Richard Biener <rguenther@suse.de>
* match.pd: Implement more patterns that simplify to a single value.
* fold-const.c (fold_binary_loc): Remove them here.
* tree-ssa-forwprop.c (simplify_bitwise_binary): Likewise.
(fwprop_ssa_val): Remove restriction on single uses.
2014-10-30 Jan-Benedict Glaw <jbglaw@lug-owl.de>
* config/avr/driver-avr.c (avr_set_current_device): Remove.

View File

@ -11089,9 +11089,6 @@ fold_binary_loc (location_t loc,
case BIT_IOR_EXPR:
bit_ior:
if (operand_equal_p (arg0, arg1, 0))
return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0));
/* ~X | X is -1. */
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0))
@ -11227,9 +11224,6 @@ fold_binary_loc (location_t loc,
goto bit_rotate;
case BIT_XOR_EXPR:
if (integer_all_onesp (arg1))
return fold_build1_loc (loc, BIT_NOT_EXPR, type, op0);
/* ~X ^ X is -1. */
if (TREE_CODE (arg0) == BIT_NOT_EXPR
&& operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0))
@ -11384,11 +11378,6 @@ fold_binary_loc (location_t loc,
goto bit_rotate;
case BIT_AND_EXPR:
if (integer_all_onesp (arg1))
return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0));
if (operand_equal_p (arg0, arg1, 0))
return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg0));
/* ~X & X, (X == 0) & X, and !X & X are always zero. */
if ((TREE_CODE (arg0) == BIT_NOT_EXPR
|| TREE_CODE (arg0) == TRUTH_NOT_EXPR

View File

@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see
/* Simplifications of operations with one constant operand and
simplifications to constants. */
simplifications to constants or single values. */
(for op (plus pointer_plus minus bit_ior bit_xor)
(simplify
@ -88,6 +88,22 @@ along with GCC; see the file COPYING3. If not see
(bit_xor @0 @0)
{ build_zero_cst (type); })
/* Canonicalize X ^ ~0 to ~X. */
(simplify
(bit_xor @0 integer_all_onesp@1)
(bit_not @0))
/* x & ~0 -> x */
(simplify
(bit_and @0 integer_all_onesp)
(non_lvalue @0))
/* x & x -> x, x | x -> x */
(for bitop (bit_and bit_ior)
(simplify
(bitop @0 @0)
(non_lvalue @0)))
/* Simplifications of conversions. */

View File

@ -2097,16 +2097,6 @@ simplify_bitwise_binary (gimple_stmt_iterator *gsi)
return true;
}
/* Canonicalize X ^ ~0 to ~X. */
if (code == BIT_XOR_EXPR
&& integer_all_onesp (arg2))
{
gimple_assign_set_rhs_with_ops (gsi, BIT_NOT_EXPR, arg1, NULL_TREE);
gcc_assert (gsi_stmt (*gsi) == stmt);
update_stmt (stmt);
return true;
}
/* Try simple folding for X op !X, and X op X. */
res = simplify_bitwise_binary_1 (code, TREE_TYPE (arg1), arg1, arg2);
if (res != NULL_TREE)
@ -3554,11 +3544,9 @@ fwprop_ssa_val (tree name)
if (val)
name = val;
}
/* If NAME is not the only use signal we don't want to continue
matching into its definition. */
if (TREE_CODE (name) == SSA_NAME
&& !has_single_use (name))
return NULL_TREE;
/* We continue matching along SSA use-def edges for SSA names
that are not single-use. Currently there are no patterns
that would cause any issues with that. */
return name;
}