aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dce.c
diff options
context:
space:
mode:
authorBin Cheng <bin.cheng@arm.com>2017-12-05 15:42:58 +0000
committerBin Cheng <amker@gcc.gnu.org>2017-12-05 15:42:58 +0000
commit23ffbafe3a3940964487fc9860ac710232ec6474 (patch)
tree6897332765c4bedaa55f4c6e1529d9fe50eafe9f /gcc/tree-ssa-dce.c
parent0382bcfcda056493544fc1bfa25030e19f465498 (diff)
downloadgcc-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-dce.c')
-rw-r--r--gcc/tree-ssa-dce.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/tree-ssa-dce.c b/gcc/tree-ssa-dce.c
index a5f0edf..8595dec 100644
--- a/gcc/tree-ssa-dce.c
+++ b/gcc/tree-ssa-dce.c
@@ -1723,3 +1723,55 @@ make_pass_cd_dce (gcc::context *ctxt)
{
return new pass_cd_dce (ctxt);
}
+
+
+/* A cheap DCE interface. WORKLIST is a list of possibly dead stmts and
+ is consumed by this function. The function has linear complexity in
+ the number of dead stmts with a constant factor like the average SSA
+ use operands number. */
+
+void
+simple_dce_from_worklist (bitmap worklist)
+{
+ 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 dead stmt:");
+ 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);
+ }
+ }
+}