GCC Middle and Back End API Reference
tree-ssa-dom.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "gimple.h"
#include "tree-pass.h"
#include "ssa.h"
#include "gimple-pretty-print.h"
#include "fold-const.h"
#include "cfganal.h"
#include "cfgloop.h"
#include "gimple-iterator.h"
#include "gimple-fold.h"
#include "tree-eh.h"
#include "tree-inline.h"
#include "tree-cfg.h"
#include "tree-into-ssa.h"
#include "domwalk.h"
#include "tree-ssa-propagate.h"
#include "tree-ssa-threadupdate.h"
#include "tree-ssa-scopedtables.h"
#include "tree-ssa-threadedge.h"
#include "tree-ssa-dom.h"
#include "gimplify.h"
#include "tree-cfgcleanup.h"
#include "dbgcnt.h"
#include "alloc-pool.h"
#include "tree-vrp.h"
#include "vr-values.h"
#include "gimple-range.h"
#include "gimple-range-path.h"
#include "alias.h"
Include dependency graph for tree-ssa-dom.cc:

Data Structures

class  edge_info
 
struct  opt_stats_d
 
class  dom_jt_state
 
class  dom_jt_simplifier
 
class  dom_opt_dom_walker
 

Functions

static void record_equality (tree, tree, class const_and_copies *)
 
static void record_equivalences_from_phis (basic_block)
 
static void record_equivalences_from_incoming_edge (basic_block, class const_and_copies *, class avail_exprs_stack *, bitmap blocks_on_stack)
 
static void eliminate_redundant_computations (gimple_stmt_iterator *, class const_and_copies *, class avail_exprs_stack *)
 
static void record_equivalences_from_stmt (gimple *, int, class avail_exprs_stack *)
 
static void dump_dominator_optimization_stats (FILE *file, hash_table< expr_elt_hasher > *)
 
static void record_temporary_equivalences (edge, class const_and_copies *, class avail_exprs_stack *, bitmap)
 
void free_dom_edge_info (edge e)
 
static void free_all_edge_infos (void)
 
static bool single_block_loop_p (basic_block bb)
 
static void record_edge_info (basic_block bb)
 
gimple_opt_passmake_pass_dominator (gcc::context *ctxt)
 
static tree dom_valueize (tree t)
 
static void back_propagate_equivalences (tree lhs, edge e, class const_and_copies *const_and_copies, bitmap domby)
 
static bool all_uses_feed_or_dominated_by_stmt (tree name, gimple *stmt)
 
static void maybe_set_nonzero_bits (edge e, tree var)
 
static void htab_statistics (FILE *file, const hash_table< expr_elt_hasher > &htab)
 
bool simple_iv_increment_p (gimple *stmt)
 
static void cprop_into_successor_phis (basic_block bb, class const_and_copies *const_and_copies)
 
static void cprop_operand (gimple *stmt, use_operand_p op_p, range_query *query)
 
static void cprop_into_stmt (gimple *stmt, range_query *query)
 
static void reduce_vector_comparison_to_scalar_comparison (gimple *stmt)
 

Variables

static bool cfg_altered
 
static bitmap need_eh_cleanup
 
static vec< gimple * > need_noreturn_fixup
 
static struct opt_stats_d opt_stats
 

Function Documentation

◆ all_uses_feed_or_dominated_by_stmt()

static bool all_uses_feed_or_dominated_by_stmt ( tree name,
gimple * stmt )
static
Return true if all uses of NAME are dominated by STMT or feed STMT
via a chain of single immediate uses.   

References CDI_DOMINATORS, dominated_by_p(), FOR_EACH_IMM_USE_FAST, ggc_alloc(), gimple_assign_lhs(), gimple_bb(), is_gimple_assign(), is_gimple_debug(), single_imm_use(), TREE_CODE, and USE_STMT.

Referenced by dom_opt_dom_walker::set_global_ranges_from_unreachable_edges().

◆ back_propagate_equivalences()

static void back_propagate_equivalences ( tree lhs,
edge e,
class const_and_copies * const_and_copies,
bitmap domby )
static
We have just found an equivalence for LHS on an edge E.
Look backwards to other uses of LHS and see if we can derive
additional equivalences that are valid on edge E.   

References bitmap_bit_p, CDI_DOMINATORS, dom_info_state(), DOM_OK, dom_valueize(), dominated_by_p(), FOR_EACH_IMM_USE_FAST, ggc_alloc(), gimple_bb(), gimple_fold_stmt_to_constant_1(), gimple_get_lhs(), is_gimple_min_invariant(), no_follow_ssa_edges(), record_equality(), TREE_CODE, and USE_STMT.

Referenced by record_temporary_equivalences().

◆ cprop_into_stmt()

static void cprop_into_stmt ( gimple * stmt,
range_query * query )
static
CONST_AND_COPIES is a table which maps an SSA_NAME to the current
known value for that SSA_NAME (or NULL if no value is known).

Propagate values from CONST_AND_COPIES into the uses, vuses and
vdef_ops of STMT.   

References cprop_operand(), FOR_EACH_SSA_USE_OPERAND, ggc_alloc(), NULL, SSA_OP_USE, TREE_CODE, and USE_FROM_PTR.

Referenced by dom_opt_dom_walker::optimize_stmt().

◆ cprop_into_successor_phis()

◆ cprop_operand()

◆ dom_valueize()

static tree dom_valueize ( tree t)
static

◆ dump_dominator_optimization_stats()

static void dump_dominator_optimization_stats ( FILE * file,
hash_table< expr_elt_hasher > * avail_exprs )
static

◆ eliminate_redundant_computations()

◆ free_all_edge_infos()

static void free_all_edge_infos ( void )
static
Free all EDGE_INFO structures associated with edges in the CFG.
If a particular edge can be threaded, copy the redirection
target from the EDGE_INFO structure into the edge's AUX field
as required by code to update the CFG and SSA graph for
jump threading.   

References cfun, FOR_EACH_BB_FN, FOR_EACH_EDGE, free_dom_edge_info(), and basic_block_def::preds.

◆ free_dom_edge_info()

void free_dom_edge_info ( edge e)
Free the edge_info data attached to E, if it exists and
clear e->aux.   

References edge_info::edge_info(), and NULL.

Referenced by edge_info::edge_info(), free_all_edge_infos(), record_edge_info(), and remove_ctrl_stmt_and_useless_edges().

◆ htab_statistics()

◆ make_pass_dominator()

gimple_opt_pass * make_pass_dominator ( gcc::context * ctxt)

References ggc_alloc().

◆ maybe_set_nonzero_bits()

static void maybe_set_nonzero_bits ( edge e,
tree var )
static

◆ record_edge_info()

◆ record_equality()

static void record_equality ( tree x,
tree y,
class const_and_copies * const_and_copies )
static
Local functions.   
Similarly, but assume that X and Y are the two operands of an EQ_EXPR.
This constrains the cases in which we may treat this as assignment.   

References dconst0, ggc_alloc(), has_single_use(), HONOR_SIGNED_ZEROS(), is_gimple_min_invariant(), NULL, real_equal(), const_and_copies::record_const_or_copy(), SSA_NAME_VALUE, TREE_CODE, TREE_REAL_CST, tree_swap_operands_p(), and y.

Referenced by back_propagate_equivalences(), and record_temporary_equivalences().

◆ record_equivalences_from_incoming_edge()

static void record_equivalences_from_incoming_edge ( basic_block bb,
class const_and_copies * const_and_copies,
class avail_exprs_stack * avail_exprs_stack,
bitmap blocks_on_stack )
static
Record any equivalences created by the incoming edge to BB into
CONST_AND_COPIES and AVAIL_EXPRS_STACK.  If BB has more than one
incoming edge, then no equivalence is created.   

References CDI_DOMINATORS, get_immediate_dominator(), ggc_alloc(), record_temporary_equivalences(), and single_pred_edge_ignoring_loop_edges().

Referenced by dom_opt_dom_walker::before_dom_children().

◆ record_equivalences_from_phis()

static void record_equivalences_from_phis ( basic_block bb)
static

◆ record_equivalences_from_stmt()

static void record_equivalences_from_stmt ( gimple * stmt,
int may_optimize_p,
class avail_exprs_stack * avail_exprs_stack )
static
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 into AVAIL_EXPRS_STACK. 

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, ggc_alloc(), 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(), avail_exprs_stack::lookup_avail_expr(), 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 dom_opt_dom_walker::optimize_stmt().

◆ record_temporary_equivalences()

static void record_temporary_equivalences ( edge e,
class const_and_copies * const_and_copies,
class avail_exprs_stack * avail_exprs_stack,
bitmap blocks_on_stack )
static
Record into CONST_AND_COPIES and AVAIL_EXPRS_STACK any equivalences implied
by traversing edge E (which are cached in E->aux).

Callers are responsible for managing the unwinding markers.   

References back_propagate_equivalences(), edge_info::cond_equivalences, eni_size_weights, estimate_num_insns(), ggc_alloc(), i, avail_exprs_stack::record_cond(), record_equality(), edge_info::simple_equivalences, SSA_NAME_DEF_STMT, and TREE_CODE.

Referenced by record_equivalences_from_incoming_edge(), and dom_jt_state::register_equivs_edge().

◆ reduce_vector_comparison_to_scalar_comparison()

static void reduce_vector_comparison_to_scalar_comparison ( gimple * stmt)
static

◆ simple_iv_increment_p()

bool simple_iv_increment_p ( gimple * stmt)
Returns true when STMT is a simple iv increment.  It detects the
following situation:

i_1 = phi (..., i_k)
[...]
i_j = i_{j-1}  for each j : 2 <= j <= k-1
[...]
i_k = i_{k-1} +/- ...   

References ggc_alloc(), gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_assign_ssa_name_copy_p(), gimple_phi_arg_def(), gimple_phi_num_args(), i, SSA_NAME_DEF_STMT, and TREE_CODE.

Referenced by eliminate_redundant_computations().

◆ single_block_loop_p()

static bool single_block_loop_p ( basic_block bb)
static
Return TRUE if BB has precisely two preds, one of which
is a backedge from a forwarder block where the forwarder
block is a direct successor of BB.  Being a forwarder
block, it has no side effects other than transfer of
control.  Otherwise return FALSE.   

References count, DECL_NONLOCAL, EDGE_COUNT, EDGE_PRED, EDGE_SUCC, ggc_alloc(), gimple_label_label(), gimple_seq_empty_p(), gsi_end_p(), gsi_last_bb(), gsi_prev(), gsi_stmt(), NULL, phi_nodes(), basic_block_def::preds, and basic_block_def::succs.

Referenced by record_edge_info().

Variable Documentation

◆ cfg_altered

bool cfg_altered
static
Track whether or not we have changed the control flow graph.   

◆ need_eh_cleanup

bitmap need_eh_cleanup
static
Bitmap of blocks that have had EH statements cleaned.  We should
remove their dead edges eventually.   

◆ need_noreturn_fixup

vec<gimple *> need_noreturn_fixup
static

◆ opt_stats