+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.
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))
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))
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
/* 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
(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. */
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)
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;
}