diff options
author | naveenh <naveenh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-21 02:22:04 +0000 |
---|---|---|
committer | naveenh <naveenh@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-21 02:22:04 +0000 |
commit | 35c8219c6aa1744e0930b5d8bc73eb10250eff39 (patch) | |
tree | 4c84786016633751aa90ea8c3ed33c0e5e030c43 /gcc/match.pd | |
parent | fa084e734327966505e29894db2e04bb24b4cbc6 (diff) | |
download | gcc-35c8219c6aa1744e0930b5d8bc73eb10250eff39.tar.gz |
2015-10-20 Richard Biener <rguenther@suse.de>
Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
* fold-const.c (fold_binary_loc) : Move (-A) * (-B) -> A * B
to match.pd.
Move (a * (1 << b)) is (a << b) to match.pd.
Move convert (C1/X)*C2 into (C1*C2)/X to match.pd.
Move ~X & X, (X == 0) & X, and !X & X are zero to match.pd.
Move X & ~X , X & (X == 0), and X & !X are zero to match.pd.
* match.pd (mult:c @0 (convert? (lshift integer_onep@1 @2))):
New simplifier.
(mult (rdiv:s REAL_CST@0 @1) REAL_CST@2): New simplifier.
(bit_and:c (convert? @0) (convert? (bit_not @0))): New simplifier.
(bit_ior (bit_and:s @0 (bit_not:s @1)) (bit_and:s (bit_not:s @0) @1))
: New simplifier.
(mult:c (convert1? (negate @0)) (convert2? negate_expr_p@1)):
New simplifier.
(match (logical_inverted_value @0) (truth_not @0)) : New Predicate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229107 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 98f4b2cbc35..83dc7ad53d1 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -325,6 +325,27 @@ along with GCC; see the file COPYING3. If not see (if (real_isinteger (&TREE_REAL_CST (@1), &n) && (n & 1) == 0) (pows @0 @1)))))) +/* Fold (a * (1 << b)) into (a << b) */ +(simplify + (mult:c @0 (convert? (lshift integer_onep@1 @2))) + (if (! FLOAT_TYPE_P (type) + && tree_nop_conversion_p (type, TREE_TYPE (@1))) + (lshift @0 @2))) + +/* Fold (C1/X)*C2 into (C1*C2)/X. */ +(simplify + (mult (rdiv:s REAL_CST@0 @1) REAL_CST@2) + (if (flag_associative_math) + (with + { tree tem = const_binop (MULT_EXPR, type, @0, @2); } + (if (tem) + (rdiv { tem; } @1))))) + +/* Simplify ~X & X as zero. */ +(simplify + (bit_and:c (convert? @0) (convert? (bit_not @0))) + { build_zero_cst (type); }) + /* X % Y is smaller than Y. */ (for cmp (lt ge) (simplify @@ -544,6 +565,13 @@ along with GCC; see the file COPYING3. If not see (match negate_expr_p VECTOR_CST (if (FLOAT_TYPE_P (TREE_TYPE (type)) || TYPE_OVERFLOW_WRAPS (type)))) + +/* (-A) * (-B) -> A * B */ +(simplify + (mult:c (convert1? (negate @0)) (convert2? negate_expr_p@1)) + (if (tree_nop_conversion_p (type, TREE_TYPE (@0)) + && tree_nop_conversion_p (type, TREE_TYPE (@1))) + (mult (convert @0) (convert (negate @1))))) /* -(A + B) -> (-B) - A. */ (simplify @@ -630,6 +658,8 @@ along with GCC; see the file COPYING3. If not see (truth_not @0)) (match (logical_inverted_value @0) + (truth_not @0)) +(match (logical_inverted_value @0) (bit_not truth_valued_p@0)) (match (logical_inverted_value @0) (eq @0 integer_zerop)) |