GCC Middle and Back End API Reference
tree-ssa-dce.c File Reference

Data Structures

struct  stmt_stats

Functions

static void set_control_dependence_map_bit ()
static void clear_control_dependence_bitmap ()
static basic_block find_pdom ()
static void find_control_dependence ()
static void find_all_control_dependences ()
static void mark_stmt_necessary ()
static void mark_operand_necessary ()
static void mark_stmt_if_obviously_necessary ()
static void mark_last_stmt_necessary ()
static void mark_control_dependent_edges_necessary (basic_block bb, struct edge_list *el, bool ignore_self)
static void find_obviously_necessary_stmts ()
static bool ref_may_be_aliased ()
static bool mark_aliased_reaching_defs_necessary_1 ()
static void mark_aliased_reaching_defs_necessary ()
static bool mark_all_reaching_defs_necessary_1 (ao_ref *ref, tree vdef, void *data)
static void mark_all_reaching_defs_necessary ()
static bool degenerate_phi_p ()
static void propagate_necessity ()
void mark_virtual_operand_for_renaming ()
void mark_virtual_phi_result_for_renaming ()
static bool remove_dead_phis ()
static edge forward_edge_to_pdom ()
static void remove_dead_stmt ()
static bool eliminate_unnecessary_stmts ()
static void print_stats ()
static void tree_dce_init ()
static void tree_dce_done ()
static unsigned int perform_tree_ssa_dce ()
static unsigned int tree_ssa_dce ()
static unsigned int tree_ssa_dce_loop ()
static unsigned int tree_ssa_cd_dce ()
static bool gate_dce ()
gimple_opt_passmake_pass_dce ()
gimple_opt_passmake_pass_dce_loop ()
gimple_opt_passmake_pass_cd_dce ()

Variables

static struct stmt_stats stats
static vec< gimpleworklist
static sbitmap processed
static sbitmap last_stmt_necessary
static sbitmap bb_contains_live_stmts
static bitmapcontrol_dependence_map
static sbitmap visited_control_parents
static bool cfg_altered
static bitmap visited = NULL
static unsigned int longest_chain = 0
static unsigned int total_chain = 0
static unsigned int nr_walks = 0
static bool chain_ovfl = false

Function Documentation

static void clear_control_dependence_bitmap ( )
inlinestatic
Clear all control dependences for block BB.   

References bitmap_clear(), and basic_block_def::index.

static bool degenerate_phi_p ( )
static
Return true for PHI nodes with one or identical arguments
   can be removed.   

References gimple_phi_arg_def(), and gimple_phi_num_args().

Referenced by forward_edge_to_pdom(), propagate_necessity(), and remove_dead_phis().

static void find_all_control_dependences ( )
static
Record all blocks' control dependences on all edges in the edge
   list EL, ala Morgan, Section 3.6.   

References find_control_dependence().

Referenced by perform_tree_ssa_dce().

static void find_control_dependence ( )
static
Determine all blocks' control dependences on the given edge with edge_list
   EL index EDGE_INDEX, ala Morgan, Section 3.6.   

References current_block, find_pdom(), edge_def::flags, set_control_dependence_map_bit(), and single_succ().

Referenced by find_all_control_dependences().

static void find_obviously_necessary_stmts ( )
static
Find obviously necessary statements.  These are things like most function
   calls, and stores to file level variables.

   If EL is NULL, control statements are conservatively marked as
   necessary.  Otherwise it contains the list of edges used by control
   dependence analysis.   

References current_function_decl, edge_def::dest, dump_file, finite_loop_p(), edge_def::flags, flags_from_decl_or_type(), gimple_set_plf(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), basic_block_def::index, loop::latch, mark_control_dependent_edges_necessary(), mark_irreducible_loops(), mark_stmt_if_obviously_necessary(), loop::num, scev_finalize(), scev_initialize(), edge_def::src, and basic_block_def::succs.

Referenced by perform_tree_ssa_dce().

static basic_block find_pdom ( )
inlinestatic
Find the immediate postdominator PDOM of the specified basic block BLOCK.
   This function is necessary because some blocks have negative numbers.   

References CDI_POST_DOMINATORS, and get_immediate_dominator().

Referenced by find_control_dependence().

static bool gate_dce ( )
static
gimple_opt_pass* make_pass_cd_dce ( )
gimple_opt_pass* make_pass_dce ( )
gimple_opt_pass* make_pass_dce_loop ( )
static void mark_aliased_reaching_defs_necessary ( )
static
static bool mark_aliased_reaching_defs_necessary_1 ( )
static
Worker for the walker that marks reaching definitions of REF,
   which is based on a non-aliased decl, necessary.  It returns
   true whenever the defining statement of the current VDEF is
   a kill for REF, as no dominating may-defs are necessary for REF
   anymore.  DATA points to the basic-block that contains the
   stmt that refers to REF.   

References ao_ref_base(), ao_ref_s::base, CDI_DOMINATORS, dominated_by_p(), get_ref_base_and_extent(), gimple_get_lhs(), gimple_has_lhs(), HOST_WIDE_INT, mark_operand_necessary(), ao_ref_s::max_size, ao_ref_s::offset, offset, operand_equal_p(), ao_ref_s::ref, and stmt_can_throw_internal().

Referenced by mark_aliased_reaching_defs_necessary().

static void mark_all_reaching_defs_necessary ( )
static
static bool mark_all_reaching_defs_necessary_1 ( ao_ref ref,
tree  vdef,
void *  data 
)
static
Worker for the walker that marks reaching definitions of REF, which
   is not based on a non-aliased decl.  For simplicity we need to end
   up marking all may-defs necessary that are not based on a non-aliased
   decl.  The only job of this walker is to skip may-defs based on
   a non-aliased decl.   

References bitmap_bit_p(), BUILT_IN_NORMAL, chain_ovfl, gimple_assign_lhs(), gimple_assign_single_p(), gimple_call_fndecl(), gimple_nop_p(), gimple_plf(), is_gimple_call(), mark_operand_necessary(), and ref_may_be_aliased().

Referenced by mark_all_reaching_defs_necessary().

static void mark_control_dependent_edges_necessary ( basic_block  bb,
struct edge_list el,
bool  ignore_self 
)
static
Mark control dependent edges of BB as necessary.  We have to do this only
   once for each basic block so we set the appropriate bit after we're done.

   When IGNORE_SELF is true, ignore BB in the list of control dependences.   

References bitmap_bit_p(), bitmap_set_bit(), basic_block_def::index, and mark_last_stmt_necessary().

Referenced by find_obviously_necessary_stmts(), and propagate_necessity().

static void mark_last_stmt_necessary ( )
static
static void mark_operand_necessary ( )
inlinestatic
static void mark_stmt_if_obviously_necessary ( )
static
static void mark_stmt_necessary ( )
inlinestatic
If STMT is not already marked necessary, mark it, and add it to the
   worklist if ADD_TO_WORKLIST is true.   

References bitmap_set_bit(), dump_file, dump_flags, gimple_plf(), gimple_set_plf(), is_gimple_debug(), and print_gimple_stmt().

Referenced by mark_last_stmt_necessary(), and mark_stmt_if_obviously_necessary().

void mark_virtual_operand_for_renaming ( )
Replace all uses of NAME by underlying variable and mark it
   for renaming.  This assumes the defining statement of NAME is
   going to be removed.   

References cfun, and mark_virtual_operands_for_renaming().

void mark_virtual_phi_result_for_renaming ( )
Replace all uses of the virtual PHI result by its underlying variable
   and mark it for renaming.  This assumes the PHI node is going to be
   removed.   

References dump_file, dump_flags, gimple_phi_result(), mark_virtual_operand_for_renaming(), and print_gimple_stmt().

static unsigned int perform_tree_ssa_dce ( )
static
Main routine to eliminate dead code.

   AGGRESSIVE controls the aggressiveness of the algorithm.
   In conservative mode, we ignore control dependence and simply declare
   all but the most trivially dead branches necessary.  This mode is fast.
   In aggressive mode, control dependences are taken into account, which
   results in more dead code elimination, but at the cost of some time.

   FIXME: Aggressive mode before PRE doesn't work currently because
          the dominance info is not invalidated after DCE1.  This is
          not an issue right now because we only run aggressive DCE
          as the last tree SSA pass, but keep this in mind when you
          start experimenting with pass ordering.   

References bitmap_clear(), calculate_dominance_info(), CDI_DOMINATORS, CDI_POST_DOMINATORS, cfg_altered, cfun, chain_ovfl, create_edge_list(), dump_file, dump_flags, eliminate_unnecessary_stmts(), find_all_control_dependences(), find_obviously_necessary_stmts(), free_dominance_info(), free_edge_list(), longest_chain, loop_optimizer_finalize(), loop_optimizer_init(), LOOPS_HAVE_RECORDED_EXITS, mark_dfs_back_edges(), nr_walks, print_stats(), propagate_necessity(), stmt_stats::removed, stmt_stats::removed_phis, sbitmap_alloc(), statistics_counter_event(), stats, timevar_pop(), timevar_push(), total_chain, tree_dce_done(), and tree_dce_init().

Referenced by tree_ssa_cd_dce(), tree_ssa_dce(), and tree_ssa_dce_loop().

static void print_stats ( )
static
Print out removed statement statistics.   

References dump_file, stmt_stats::removed, stmt_stats::removed_phis, stats, stmt_stats::total, and stmt_stats::total_phis.

Referenced by perform_tree_ssa_dce().

static bool ref_may_be_aliased ( )
static
Return true if REF is based on an aliased base, otherwise false.   

References handled_component_p(), and may_be_aliased().

Referenced by mark_all_reaching_defs_necessary_1(), and propagate_necessity().

static void set_control_dependence_map_bit ( )
inlinestatic
Indicate block BB is control dependent on an edge with index EDGE_INDEX.   

References bitmap_set_bit(), and basic_block_def::index.

Referenced by find_control_dependence().

static void tree_dce_done ( )
static
Cleanup after this pass.   

References free(), and sbitmap_free().

Referenced by perform_tree_ssa_dce().

static void tree_dce_init ( )
static
Initialization for this pass.  Set up the used data structures.   

References bitmap_clear(), cfg_altered, memset(), sbitmap_alloc(), and stats.

Referenced by perform_tree_ssa_dce().

static unsigned int tree_ssa_cd_dce ( )
static
static unsigned int tree_ssa_dce ( )
static
Pass entry points.   

References perform_tree_ssa_dce().

static unsigned int tree_ssa_dce_loop ( )
static

Variable Documentation

sbitmap bb_contains_live_stmts
static
Vector indicating that BB contains statements that are live.   
bool cfg_altered
static
TRUE if this pass alters the CFG (by removing control statements).
   FALSE otherwise.

   If this pass alters the CFG, then it will arrange for the dominators
   to be recomputed.   

Referenced by convert_regs(), convert_regs_1(), convert_regs_2(), eliminate_unnecessary_stmts(), forward_edge_to_pdom(), perform_tree_ssa_dce(), remove_dead_stmt(), and tree_dce_init().

bitmap* control_dependence_map
static
Before we can determine whether a control branch is dead, we need to
   compute which blocks are control dependent on which edges.

   We expect each block to be control dependent on very few edges so we
   use a bitmap for each block recording its edges.  An array holds the
   bitmap.  The Ith bit in the bitmap is set if that block is dependent
   on the Ith edge.   
sbitmap last_stmt_necessary
static
Vector indicating that the last statement of a basic block has already
   been marked as necessary.   
unsigned int longest_chain = 0
static
unsigned int nr_walks = 0
static
sbitmap processed
static
Vector indicating an SSA name has already been processed and marked
   as necessary.   

Referenced by build_rdg_partition_for_component(), estimate_shadow_tick(), fast_dce(), fix_inter_tick(), and ldist_gen().

unsigned int total_chain = 0
static
sbitmap visited_control_parents
static
Vector indicating that a basic block has already had all the edges
   processed that it is control dependent on.   
vec<gimple> worklist
static