GCC Middle and Back End API Reference
dom_opt_dom_walker Class Reference
Inheritance diagram for dom_opt_dom_walker:
Collaboration diagram for dom_opt_dom_walker:

Public Types

enum  reachability { ALL_BLOCKS , REACHABLE_BLOCKS , REACHABLE_BLOCKS_PRESERVING_FLAGS }

Public Member Functions

 dom_opt_dom_walker (cdi_direction direction, jump_threader *threader, dom_jt_state *state, gimple_ranger *ranger, const_and_copies *const_and_copies, avail_exprs_stack *avail_exprs_stack)
edge before_dom_children (basic_block) final override
void after_dom_children (basic_block) final override
void walk (basic_block)

Static Public Attributes

static const edge STOP = (edge)-1

Private Member Functions

edge optimize_stmt (basic_block, gimple_stmt_iterator *, bool *)
void set_global_ranges_from_unreachable_edges (basic_block)
void fold_cond (gimple *)
void record_equivalences_from_incoming_edge (basic_block)
void eliminate_redundant_computations (gimple_stmt_iterator *)
void record_equivalences_from_stmt (gimple *, int)
tree const_or_copy_of_stmt (gimple *)
bool bb_reachable (struct function *, basic_block)
void propagate_unreachable_to_edges (basic_block, FILE *, dump_flags_t)

Private Attributes

class const_and_copies * m_const_and_copies
class avail_exprs_stack * m_avail_exprs_stack
jump_threader * m_threader
gimple_ranger * m_ranger
dom_jt_state * m_state
enum cdi_direction m_dom_direction: 2
enum reachability m_reachability: 2
bool m_user_bb_to_rpo
basic_block m_unreachable_dom
int * m_bb_to_rpo

Member Enumeration Documentation

◆ reachability

enum dom_walker::reachability
inherited
Enumerator
ALL_BLOCKS 
REACHABLE_BLOCKS 
REACHABLE_BLOCKS_PRESERVING_FLAGS 

Constructor & Destructor Documentation

◆ dom_opt_dom_walker()

dom_opt_dom_walker::dom_opt_dom_walker ( cdi_direction direction,
jump_threader * threader,
dom_jt_state * state,
gimple_ranger * ranger,
const_and_copies * const_and_copies,
avail_exprs_stack * avail_exprs_stack )
inline

Member Function Documentation

◆ after_dom_children()

void dom_opt_dom_walker::after_dom_children ( basic_block bb)
finaloverridevirtual
We have finished processing the dominator children of BB, perform
any finalization actions in preparation for leaving this node in
the dominator tree.   

Reimplemented from dom_walker.

References bitmap_clear_bit(), basic_block_def::index, m_avail_exprs_stack, m_const_and_copies, m_state, and m_threader.

◆ bb_reachable()

bool dom_walker::bb_reachable ( struct function * fun,
basic_block bb )
privateinherited
Return TRUE if BB is reachable, false otherwise.   

References ALL_BLOCKS, CDI_DOMINATORS, dominated_by_p(), ENTRY_BLOCK_PTR_FOR_FN, FOR_EACH_EDGE, m_reachability, m_unreachable_dom, and basic_block_def::preds.

Referenced by walk().

◆ before_dom_children()

◆ const_or_copy_of_stmt()

tree dom_opt_dom_walker::const_or_copy_of_stmt ( gimple * stmt)
private
Return the constant STMT computes, and barring that, an operand its
result is equivalent to.  NULL if neither.   

References gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_class(), GIMPLE_BINARY_RHS, is_gimple_assign(), m_ranger, NULL_TREE, and VREL_EQ.

Referenced by eliminate_redundant_computations().

◆ eliminate_redundant_computations()

◆ fold_cond()

void dom_opt_dom_walker::fold_cond ( gimple * stmt)
private
Fold the conditional STMT with range info.   

References dyn_cast(), gimple_set_modified(), m_ranger, and simplify::simplify().

Referenced by optimize_stmt().

◆ optimize_stmt()

edge dom_opt_dom_walker::optimize_stmt ( basic_block bb,
gimple_stmt_iterator * si,
bool * removed_p )
private
Optimize the statement in block BB pointed to by iterator SI.

We try to perform some simplistic global redundancy elimination and
constant propagation:

1- To detect global redundancy, we keep track of expressions that have
   been computed in this block and its dominators.  If we find that the
   same expression is computed more than once, we eliminate repeated
   computations by using the target of the first one.

2- Constant values and copy assignments.  This is used to do very
   simplistic constant and copy propagation.  When a constant or copy
   assignment is found, we map the value on the RHS of the assignment to
   the variable in the LHS in the CONST_AND_COPIES table.

3- Very simple redundant store elimination is performed.

4- We can simplify a condition to a constant or from a relational
   condition to an equality condition.   

References as_a(), bitmap_set_bit, boolean_type_node, cfg_altered, cprop_into_stmt(), DECL_HARD_REGISTER, dom_valueize(), dump_file, dump_flags, dyn_cast(), eliminate_redundant_computations(), expr_hash_elt::expr(), EXPR_SINGLE, find_taken_edge(), fndecl_built_in_p(), fold_binary_loc(), fold_cond(), fold_stmt(), gcc_unreachable, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_single_p(), gimple_bb(), gimple_build_assign(), gimple_call_fndecl(), gimple_call_lhs(), gimple_call_noreturn_p(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_make_false(), gimple_cond_make_true(), gimple_cond_rhs(), gimple_goto_dest(), gimple_has_side_effects(), gimple_location(), gimple_modified_p(), gimple_set_modified(), gimple_set_vuse(), gimple_switch_index(), gimple_vuse(), gsi_remove(), gsi_stmt(), basic_block_def::index, integer_onep(), integer_zero_node, integer_zerop(), is_gimple_assign(), is_gimple_call(), hashable_expr::kind, m_avail_exprs_stack, m_ranger, maybe_clean_or_replace_eh_stmt(), need_eh_cleanup, need_noreturn_fixup, NULL, NULL_TREE, opt_stats_d::num_stmts, operand_equal_p(), hashable_expr::ops, opt_stats, print_gimple_stmt(), propagate_tree_value_into_stmt(), recompute_tree_invariant_for_addr_expr(), record_equivalences_from_stmt(), reduce_vector_comparison_to_scalar_comparison(), refs_same_for_tbaa_p(), release_defs(), si, SSA_NAME_DEF_STMT, TDF_DETAILS, TDF_SLIM, TREE_CODE, unlink_stmt_vdef(), and update_stmt_if_modified().

Referenced by before_dom_children().

◆ propagate_unreachable_to_edges()

void dom_walker::propagate_unreachable_to_edges ( basic_block bb,
FILE * dump_file,
dump_flags_t dump_flags )
privateinherited
BB has been determined to be unreachable.  Propagate that property
to incoming and outgoing edges of BB as appropriate.   

References CDI_DOMINATORS, dominated_by_p(), dump_file, dump_flags, FOR_EACH_EDGE, basic_block_def::index, m_unreachable_dom, basic_block_def::preds, basic_block_def::succs, and TDF_DETAILS.

Referenced by walk().

◆ record_equivalences_from_incoming_edge()

void dom_opt_dom_walker::record_equivalences_from_incoming_edge ( basic_block bb)
private
Record any equivalences created by the incoming edge to BB.  If BB
has more than one incoming edge, then no equivalence is created.   

References CDI_DOMINATORS, get_immediate_dominator(), m_avail_exprs_stack, m_const_and_copies, m_state, record_temporary_equivalences(), and single_pred_edge_ignoring_loop_edges().

Referenced by before_dom_children().

◆ record_equivalences_from_stmt()

void dom_opt_dom_walker::record_equivalences_from_stmt ( gimple * stmt,
int may_optimize_p )
private
STMT, a GIMPLE_ASSIGN, may create certain equivalences, in either
the available expressions table or the const_and_copies table.
Detect and record those equivalences.

We handle only very simple copy equivalences here.  The heavy
lifing is done by eliminate_redundant_computations.   

References build1(), dom_valueize(), dump_file, dump_flags, fold_build2, fold_convert, gcc_assert, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_assign_single_p(), gimple_build_assign(), gimple_has_volatile_ops(), gimple_references_memory_p(), gimple_set_vuse(), gimple_vdef(), is_gimple_assign(), is_gimple_min_invariant(), is_gimple_reg(), m_avail_exprs_stack, print_generic_expr(), ptr_type_node, set_ssa_name_value(), SSA_NAME_DEF_STMT, TDF_DETAILS, TREE_CODE, TREE_TYPE, and unshare_expr().

Referenced by optimize_stmt().

◆ set_global_ranges_from_unreachable_edges()

void dom_opt_dom_walker::set_global_ranges_from_unreachable_edges ( basic_block bb)
private
Set global ranges that can be determined from the C->M edge:

  <bb C>:
  ...
  if (something)
    goto <bb N>;
  else
    goto <bb M>;
  <bb N>:
  __builtin_unreachable ();
  <bb M>:

References all_uses_feed_or_dominated_by_stmt(), assert_unreachable_fallthru_edge_p(), FOR_EACH_GORI_EXPORT_NAME, gimple_bb(), gimple_cond_lhs(), gimple_cond_rhs(), gsi_last_bb(), m_ranger, maybe_set_nonzero_bits(), r, set_range_info(), single_pred_edge_ignoring_loop_edges(), SSA_NAME_DEF_STMT, SSA_NAME_IS_DEFAULT_DEF, TREE_CODE, and TREE_TYPE.

Referenced by before_dom_children().

◆ walk()

Field Documentation

◆ m_avail_exprs_stack

◆ m_bb_to_rpo

int* dom_walker::m_bb_to_rpo
privateinherited

Referenced by dom_walker(), walk(), and ~dom_walker().

◆ m_const_and_copies

◆ m_dom_direction

enum cdi_direction dom_walker::m_dom_direction
privateinherited

Referenced by dom_walker(), and walk().

◆ m_ranger

◆ m_reachability

enum reachability dom_walker::m_reachability
privateinherited

Referenced by bb_reachable(), dom_walker(), and walk().

◆ m_state

◆ m_threader

jump_threader* dom_opt_dom_walker::m_threader
private

◆ m_unreachable_dom

basic_block dom_walker::m_unreachable_dom
privateinherited

◆ m_user_bb_to_rpo

bool dom_walker::m_user_bb_to_rpo
privateinherited

Referenced by dom_walker(), walk(), and ~dom_walker().

◆ STOP

const edge dom_walker::STOP = (edge)-1
staticinherited

The documentation for this class was generated from the following file: