diff options
author | Bin Cheng <bin.cheng@arm.com> | 2017-12-05 15:42:58 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2017-12-05 15:42:58 +0000 |
commit | 23ffbafe3a3940964487fc9860ac710232ec6474 (patch) | |
tree | 6897332765c4bedaa55f4c6e1529d9fe50eafe9f /gcc/tree-ssa-pre.c | |
parent | 0382bcfcda056493544fc1bfa25030e19f465498 (diff) | |
download | gcc-23ffbafe3a3940964487fc9860ac710232ec6474.zip gcc-23ffbafe3a3940964487fc9860ac710232ec6474.tar.gz gcc-23ffbafe3a3940964487fc9860ac710232ec6474.tar.bz2 |
tree-ssa-dce.c (simple_dce_from_worklist): Move and rename from tree-ssa-pre.c::remove_dead_inserted_code.
* tree-ssa-dce.c (simple_dce_from_worklist): Move and rename from
tree-ssa-pre.c::remove_dead_inserted_code.
* tree-ssa-dce.h: New file.
* tree-ssa-pre.c (tree-ssa-dce.h): Include new header file.
(remove_dead_inserted_code): Move and rename to function
tree-ssa-dce.c::simple_dce_from_worklist.
(pass_pre::execute): Update use.
From-SVN: r255426
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r-- | gcc/tree-ssa-pre.c | 65 |
1 files changed, 6 insertions, 59 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index a9dcd5e..999b881 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "dbgcnt.h" #include "domwalk.h" #include "tree-ssa-propagate.h" +#include "tree-ssa-dce.h" #include "tree-cfgcleanup.h" #include "alias.h" @@ -3995,64 +3996,6 @@ compute_avail (void) free (worklist); } -/* Cheap DCE of a known set of possibly dead stmts. - - Because we don't follow exactly the standard PRE algorithm, and decide not - to insert PHI nodes sometimes, and because value numbering of casts isn't - perfect, we sometimes end up inserting dead code. This simple DCE-like - pass removes any insertions we made that weren't actually used. */ - -static void -remove_dead_inserted_code (void) -{ - /* ??? Re-use inserted_exprs as worklist not only as initial set. - This may end up removing non-inserted code as well. If we - keep inserted_exprs unchanged we could restrict new worklist - elements to members of inserted_exprs. */ - bitmap worklist = inserted_exprs; - while (! bitmap_empty_p (worklist)) - { - /* Pop item. */ - unsigned i = bitmap_first_set_bit (worklist); - bitmap_clear_bit (worklist, i); - - tree def = ssa_name (i); - /* Removed by somebody else or still in use. */ - if (! def || ! has_zero_uses (def)) - continue; - - gimple *t = SSA_NAME_DEF_STMT (def); - if (gimple_has_side_effects (t)) - continue; - - /* Add uses to the worklist. */ - ssa_op_iter iter; - use_operand_p use_p; - FOR_EACH_PHI_OR_STMT_USE (use_p, t, iter, SSA_OP_USE) - { - tree use = USE_FROM_PTR (use_p); - if (TREE_CODE (use) == SSA_NAME - && ! SSA_NAME_IS_DEFAULT_DEF (use)) - bitmap_set_bit (worklist, SSA_NAME_VERSION (use)); - } - - /* Remove stmt. */ - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Removing unnecessary insertion:"); - print_gimple_stmt (dump_file, t, 0); - } - gimple_stmt_iterator gsi = gsi_for_stmt (t); - if (gimple_code (t) == GIMPLE_PHI) - remove_phi_node (&gsi, true); - else - { - gsi_remove (&gsi, true); - release_defs (t); - } - } -} - /* Initialize data structures used by PRE. */ @@ -4188,7 +4131,11 @@ pass_pre::execute (function *fun) /* Remove all the redundant expressions. */ todo |= vn_eliminate (inserted_exprs); - remove_dead_inserted_code (); + /* Because we don't follow exactly the standard PRE algorithm, and decide not + to insert PHI nodes sometimes, and because value numbering of casts isn't + perfect, we sometimes end up inserting dead code. This simple DCE-like + pass removes any insertions we made that weren't actually used. */ + simple_dce_from_worklist (inserted_exprs); fini_pre (); |