Commit a499aac5 by Richard Biener Committed by Richard Biener

match.pd: Add patterns for POINTER_PLUS_EXPR association and special patterns from...

2014-11-07  Richard Biener  <rguenther@suse.de>

	* match.pd: Add patterns for POINTER_PLUS_EXPR association
	and special patterns from tree-ssa-forwprop.c
	* fold-const.c (fold_binary_loc): Remove them here.
	* tree-ssa-forwprop.c (to_purge): New global bitmap.
	(fwprop_set_lattice_val): New function.
	(fwprop_invalidate_lattice): Likewise.
	(remove_prop_source_from_use): Instead of purging dead EH
	edges record blocks to do that in to_purge.
	(tidy_after_forward_propagate_addr): Likewise.
	(forward_propagate_addr_expr): Invalidate the lattice for
	SSA names we release.
	(simplify_conversion_from_bitmask): Likewise.
	(simplify_builtin_call): Likewise.
	(associate_pointerplus_align): Remove.
	(associate_pointerplus_diff): Likewise.
	(associate_pointerplus): Likewise.
	(fold_all_stmts): Merge with ...
	(pass_forwprop::execute): ... the original loop over all
	basic-blocks.  Delay purging dead EH edges and invalidate
	the lattice for SSA names we release.

From-SVN: r217213
parent a8cfbbdc
2014-11-07 Richard Biener <rguenther@suse.de>
* match.pd: Add patterns for POINTER_PLUS_EXPR association
and special patterns from tree-ssa-forwprop.c
* fold-const.c (fold_binary_loc): Remove them here.
* tree-ssa-forwprop.c (to_purge): New global bitmap.
(fwprop_set_lattice_val): New function.
(fwprop_invalidate_lattice): Likewise.
(remove_prop_source_from_use): Instead of purging dead EH
edges record blocks to do that in to_purge.
(tidy_after_forward_propagate_addr): Likewise.
(forward_propagate_addr_expr): Invalidate the lattice for
SSA names we release.
(simplify_conversion_from_bitmask): Likewise.
(simplify_builtin_call): Likewise.
(associate_pointerplus_align): Remove.
(associate_pointerplus_diff): Likewise.
(associate_pointerplus): Likewise.
(fold_all_stmts): Merge with ...
(pass_forwprop::execute): ... the original loop over all
basic-blocks. Delay purging dead EH edges and invalidate
the lattice for SSA names we release.
2014-11-07 Terry Guo <terry.guo@arm.com> 2014-11-07 Terry Guo <terry.guo@arm.com>
* config/arm/arm.opt (masm-syntax-unified): New option. * config/arm/arm.opt (masm-syntax-unified): New option.
...@@ -10009,10 +10009,6 @@ fold_binary_loc (location_t loc, ...@@ -10009,10 +10009,6 @@ fold_binary_loc (location_t loc,
return NULL_TREE; return NULL_TREE;
case POINTER_PLUS_EXPR: case POINTER_PLUS_EXPR:
/* 0 +p index -> (type)index */
if (integer_zerop (arg0))
return non_lvalue_loc (loc, fold_convert_loc (loc, type, arg1));
/* INT +p INT -> (PTR)(INT + INT). Stripping types allows for this. */ /* INT +p INT -> (PTR)(INT + INT). Stripping types allows for this. */
if (INTEGRAL_TYPE_P (TREE_TYPE (arg1)) if (INTEGRAL_TYPE_P (TREE_TYPE (arg1))
&& INTEGRAL_TYPE_P (TREE_TYPE (arg0))) && INTEGRAL_TYPE_P (TREE_TYPE (arg0)))
...@@ -10023,19 +10019,6 @@ fold_binary_loc (location_t loc, ...@@ -10023,19 +10019,6 @@ fold_binary_loc (location_t loc,
fold_convert_loc (loc, sizetype, fold_convert_loc (loc, sizetype,
arg0))); arg0)));
/* (PTR +p B) +p A -> PTR +p (B + A) */
if (TREE_CODE (arg0) == POINTER_PLUS_EXPR)
{
tree inner;
tree arg01 = fold_convert_loc (loc, sizetype, TREE_OPERAND (arg0, 1));
tree arg00 = TREE_OPERAND (arg0, 0);
inner = fold_build2_loc (loc, PLUS_EXPR, sizetype,
arg01, fold_convert_loc (loc, sizetype, arg1));
return fold_convert_loc (loc, type,
fold_build_pointer_plus_loc (loc,
arg00, inner));
}
/* PTR_CST +p CST -> CST1 */ /* PTR_CST +p CST -> CST1 */
if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST) if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST)
return fold_build2_loc (loc, PLUS_EXPR, type, arg0, return fold_build2_loc (loc, PLUS_EXPR, type, arg0,
......
...@@ -39,6 +39,11 @@ along with GCC; see the file COPYING3. If not see ...@@ -39,6 +39,11 @@ along with GCC; see the file COPYING3. If not see
(op @0 integer_zerop) (op @0 integer_zerop)
(non_lvalue @0))) (non_lvalue @0)))
/* 0 +p index -> (type)index */
(simplify
(pointer_plus integer_zerop @1)
(non_lvalue (convert @1)))
/* Simplify x - x. /* Simplify x - x.
This is unsafe for certain floats even in non-IEEE formats. This is unsafe for certain floats even in non-IEEE formats.
In IEEE, it is unsafe because it does wrong for NaNs. In IEEE, it is unsafe because it does wrong for NaNs.
...@@ -228,19 +233,50 @@ along with GCC; see the file COPYING3. If not see ...@@ -228,19 +233,50 @@ along with GCC; see the file COPYING3. If not see
&& TYPE_PRECISION (TREE_TYPE (@1)) == 1) && TYPE_PRECISION (TREE_TYPE (@1)) == 1)
(le @0 @1))) (le @0 @1)))
/* From tree-ssa-forwprop.c:simplify_not_neg_expr. */
/* ~~x -> x */ /* ~~x -> x */
(simplify (simplify
(bit_not (bit_not @0)) (bit_not (bit_not @0))
@0) @0)
/* The corresponding (negate (negate @0)) -> @0 is in match-plusminus.pd. */
(simplify (simplify
(negate (negate @0)) (negate (negate @0))
@0) @0)
/* Associate (p +p off1) +p off2 as (p +p (off1 + off2)). */
(simplify
(pointer_plus (pointer_plus @0 @1) @3)
(pointer_plus @0 (plus @1 @3)))
/* Pattern match
tem1 = (long) ptr1;
tem2 = (long) ptr2;
tem3 = tem2 - tem1;
tem4 = (unsigned long) tem3;
tem5 = ptr1 + tem4;
and produce
tem5 = ptr2; */
(simplify
(pointer_plus @0 (convert?@2 (minus@3 (convert @1) (convert @0))))
/* Conditionally look through a sign-changing conversion. */
(if (TYPE_PRECISION (TREE_TYPE (@2)) == TYPE_PRECISION (TREE_TYPE (@3))
&& ((GIMPLE && useless_type_conversion_p (type, TREE_TYPE (@1)))
|| (GENERIC && type == TREE_TYPE (@1))))
@1))
/* Pattern match
tem = (sizetype) ptr;
tem = tem & algn;
tem = -tem;
... = ptr p+ tem;
and produce the simpler and easier to analyze with respect to alignment
... = ptr & ~algn; */
(simplify
(pointer_plus @0 (negate (bit_and (convert @0) INTEGER_CST@1)))
(with { tree algn = wide_int_to_tree (TREE_TYPE (@0), wi::bit_not (@1)); }
(bit_and @0 { algn; })))
/* Simplifications of conversions. */ /* Simplifications of conversions. */
/* Basic strip-useless-type-conversions / strip_nops. */ /* Basic strip-useless-type-conversions / strip_nops. */
......
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