diff options
author | Richard Biener <rguenther@suse.de> | 2014-11-07 09:00:32 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2014-11-07 09:00:32 +0000 |
commit | a499aac5dfa5d9be4945c162167d13cfc07b2a81 (patch) | |
tree | 696202c55daf649efb88070f8b62853e03d748c2 /gcc/match.pd | |
parent | a8cfbbdc7413f05278fa54d4c4644ec6eb5d943b (diff) | |
download | gcc-a499aac5dfa5d9be4945c162167d13cfc07b2a81.zip gcc-a499aac5dfa5d9be4945c162167d13cfc07b2a81.tar.gz gcc-a499aac5dfa5d9be4945c162167d13cfc07b2a81.tar.bz2 |
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
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 0c7ef56..bbff19a 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -39,6 +39,11 @@ along with GCC; see the file COPYING3. If not see (op @0 integer_zerop) (non_lvalue @0))) +/* 0 +p index -> (type)index */ +(simplify + (pointer_plus integer_zerop @1) + (non_lvalue (convert @1))) + /* Simplify x - x. This is unsafe for certain floats even in non-IEEE formats. 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 && TYPE_PRECISION (TREE_TYPE (@1)) == 1) (le @0 @1))) -/* From tree-ssa-forwprop.c:simplify_not_neg_expr. */ - /* ~~x -> x */ (simplify (bit_not (bit_not @0)) @0) -/* The corresponding (negate (negate @0)) -> @0 is in match-plusminus.pd. */ (simplify (negate (negate @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. */ /* Basic strip-useless-type-conversions / strip_nops. */ |