diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-11-10 15:45:55 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-11-10 15:45:55 +0000 |
commit | 6f5ffe814333e99bcba2ff2e23c391ad177b672c (patch) | |
tree | 88c8cade21e8b1b63b0c857578fd173e5cbff792 | |
parent | 42dd613317e881cfb529657ba821105d172dc768 (diff) | |
download | gcc-6f5ffe814333e99bcba2ff2e23c391ad177b672c.tar.gz |
2014-11-10 Richard Biener <rguenther@suse.de>
* match.pd: Implement pattern from simplify_mult.
* tree-ssa-forwprop.c (simplify_mult): Remove.
(pass_forwprop::execute): Do not call simplify_mult.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217290 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/match.pd | 8 | ||||
-rw-r--r-- | gcc/tree-ssa-forwprop.c | 55 |
3 files changed, 14 insertions, 55 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 663ba2c9748..784c57a9b75 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2014-11-10 Richard Biener <rguenther@suse.de> + * match.pd: Implement pattern from simplify_mult. + * tree-ssa-forwprop.c (simplify_mult): Remove. + (pass_forwprop::execute): Do not call simplify_mult. + +2014-11-10 Richard Biener <rguenther@suse.de> + PR tree-optimization/63800 * tree-ssa-pre.c (eliminate_push_avail): Push in a way so we can restore the previous availability in after_dom_children. diff --git a/gcc/match.pd b/gcc/match.pd index c88beb94b75..f4f9b8dca39 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -443,3 +443,11 @@ along with GCC; see the file COPYING3. If not see && operand_equal_p (@1, build_low_bits_mask (TREE_TYPE (@1), TYPE_PRECISION (type)), 0)) (convert @0))) + + +/* (X /[ex] A) * A -> X. */ +(simplify + (mult (convert? (exact_div @0 @1)) @1) + /* Look through a sign-changing conversion. */ + (if (TYPE_PRECISION (TREE_TYPE (@0)) == TYPE_PRECISION (type)) + (convert @0))) diff --git a/gcc/tree-ssa-forwprop.c b/gcc/tree-ssa-forwprop.c index 0507bc05d4e..2d6a9fb8638 100644 --- a/gcc/tree-ssa-forwprop.c +++ b/gcc/tree-ssa-forwprop.c @@ -2588,54 +2588,6 @@ simplify_vector_constructor (gimple_stmt_iterator *gsi) return true; } -/* Simplify multiplications. - Return true if a transformation applied, otherwise return false. */ - -static bool -simplify_mult (gimple_stmt_iterator *gsi) -{ - gimple stmt = gsi_stmt (*gsi); - tree arg1 = gimple_assign_rhs1 (stmt); - tree arg2 = gimple_assign_rhs2 (stmt); - - if (TREE_CODE (arg1) != SSA_NAME) - return false; - - gimple def_stmt = SSA_NAME_DEF_STMT (arg1); - if (!is_gimple_assign (def_stmt)) - return false; - - /* Look through a sign-changing conversion. */ - if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))) - { - if (TYPE_PRECISION (TREE_TYPE (gimple_assign_lhs (def_stmt))) - != TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (def_stmt))) - || TREE_CODE (gimple_assign_rhs1 (def_stmt)) != SSA_NAME) - return false; - def_stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_stmt)); - if (!is_gimple_assign (def_stmt)) - return false; - } - - if (gimple_assign_rhs_code (def_stmt) == EXACT_DIV_EXPR) - { - if (operand_equal_p (gimple_assign_rhs2 (def_stmt), arg2, 0)) - { - tree res = gimple_assign_rhs1 (def_stmt); - if (useless_type_conversion_p (TREE_TYPE (arg1), TREE_TYPE (res))) - gimple_assign_set_rhs_with_ops (gsi, TREE_CODE (res), res, - NULL_TREE); - else - gimple_assign_set_rhs_with_ops (gsi, NOP_EXPR, res, NULL_TREE); - gcc_assert (gsi_stmt (*gsi) == stmt); - update_stmt (stmt); - return true; - } - } - - return false; -} - /* Primitive "lattice" function for gimple_simplify. */ @@ -2853,13 +2805,6 @@ pass_forwprop::execute (function *fun) || code == BIT_XOR_EXPR) && simplify_rotate (&gsi)) changed = true; - else if (code == MULT_EXPR) - { - changed = simplify_mult (&gsi); - if (changed - && maybe_clean_or_replace_eh_stmt (stmt, stmt)) - bitmap_set_bit (to_purge, bb->index); - } else if (code == PLUS_EXPR || code == MINUS_EXPR) { |