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

Data Structures

struct  same_succ_def
struct  bb_cluster_def
struct  aux_bb_info

Typedefs

typedef struct same_succ_defsame_succ
typedef struct same_succ_defconst_same_succ
typedef struct bb_cluster_defbb_cluster
typedef struct bb_cluster_defconst_bb_cluster

Functions

static bool stmt_local_def ()
static void gsi_advance_fw_nondebug_nonlocal ()
static bool gvn_uses_equal ()
static void same_succ_print ()
int ssa_same_succ_print_traverse ()
static void update_dep_bb ()
static void stmt_update_dep_bb ()
static hashval_t same_succ_hash ()
static bool inverse_flags ()
static same_succ same_succ_alloc ()
static void same_succ_reset ()
void debug_same_succ (void)
static void print_worklist ()
static void add_to_worklist ()
static void find_same_succ_bb ()
static void find_same_succ ()
static void init_worklist ()
static void delete_worklist ()
static void mark_basic_block_deleted ()
static void same_succ_flush_bb ()
static void same_succ_flush_bbs ()
static void release_last_vdef ()
static void update_worklist ()
static void print_cluster ()
void debug_cluster (bb_cluster)
DEBUG_FUNCTION void debug_cluster ()
static void update_rep_bb ()
static void add_bb_to_cluster ()
static bb_cluster new_cluster ()
static void delete_cluster ()
static void alloc_cluster_vectors ()
static void reset_cluster_vectors ()
static void delete_cluster_vectors ()
static void merge_clusters ()
static void set_cluster ()
static bool gimple_equal_p ()
static void gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi, tree *vuse, bool *vuse_escaped)
static void find_duplicate ()
static bool same_phi_alternatives_1 ()
static bool same_phi_alternatives ()
static bool bb_has_non_vop_phi ()
static bool deps_ok_for_redirect_from_bb_to_bb ()
static bool deps_ok_for_redirect ()
static void find_clusters_1 ()
static void find_clusters ()
static gimple vop_phi ()
static void replace_block_by ()
static int apply_clusters ()
static void update_debug_stmt ()
static void update_debug_stmts ()
unsigned int tail_merge_optimize ()

Variables

static hash_table< same_succ_defsame_succ_htab
static int * same_succ_edge_flags
static bitmap deleted_bbs
static bitmap deleted_bb_preds
static vec< same_succworklist
static vec< bb_clusterall_clusters
static bitmap update_bbs

Typedef Documentation

typedef struct bb_cluster_def* bb_cluster
typedef struct same_succ_def* const_same_succ
typedef struct same_succ_def* same_succ

Function Documentation

static void add_bb_to_cluster ( )
static
Add BB to cluster C.  Sets BB in C->bbs, and preds of BB in C->preds.   

References bb_cluster_def::bbs, bitmap_set_bit(), basic_block_def::index, basic_block_def::preds, bb_cluster_def::preds, edge_def::src, and update_rep_bb().

Referenced by set_cluster().

static void add_to_worklist ( )
static
Adds SAME to worklist.   

References same_succ_def::bbs, bitmap_count_bits(), and same_succ_def::in_worklist.

Referenced by find_same_succ_bb().

static void alloc_cluster_vectors ( )
static
Allocate all cluster vectors.   

Referenced by tail_merge_optimize().

static int apply_clusters ( )
static
For each cluster in all_clusters, merge all cluster->bbs.  Returns
   number of bbs removed.   

References bb_cluster_def::bbs, bitmap_clear_bit(), bitmap_set_bit(), basic_block_def::index, bb_cluster_def::rep_bb, and replace_block_by().

Referenced by tail_merge_optimize().

static bool bb_has_non_vop_phi ( )
static
Return true if BB has non-vop phis.   

References gimple_phi_result(), gimple_seq_first_stmt(), gimple_seq_singleton_p(), phi_nodes(), phis, and virtual_operand_p().

Referenced by find_clusters_1().

void debug_cluster ( bb_cluster  )
Prints cluster C to stderr.   
DEBUG_FUNCTION void debug_cluster ( )

References print_cluster().

DEBUG_FUNCTION void debug_same_succ ( void  )
Prints same_succ_htab to stderr.   

References ssa_same_succ_print_traverse(), and hash_table< Descriptor, Allocator >::traverse().

static void delete_cluster ( )
static
static void delete_cluster_vectors ( )
static
Delete all cluster vectors.   

References delete_cluster().

Referenced by tail_merge_optimize().

static void delete_worklist ( )
static
static bool deps_ok_for_redirect ( )
static
Returns true if replacing BB1 (or its replacement bb) by BB2 (or its
   replacement bb) and vice versa maintains the invariant that uses in the
   replacement are dominates by their defs.   

References deps_ok_for_redirect_from_bb_to_bb().

Referenced by find_clusters_1().

static bool deps_ok_for_redirect_from_bb_to_bb ( )
static
Returns true if redirecting the incoming edges of FROM to TO maintains the
   invariant that uses in FROM are dominates by their defs.   

References bitmap_set_bit(), CDI_DOMINATORS, dominated_by_p(), basic_block_def::index, nearest_common_dominator_for_set(), basic_block_def::preds, and edge_def::src.

Referenced by deps_ok_for_redirect().

static void find_clusters ( )
static
Find clusters of bbs which can be merged.   

References dump_file, dump_flags, find_clusters_1(), same_succ_def::in_worklist, and same_succ_print().

Referenced by tail_merge_optimize().

static void find_clusters_1 ( )
static
Within SAME_SUCC->bbs, find clusters of bbs which can be merged.   

References bb_has_non_vop_phi(), same_succ_def::bbs, deps_ok_for_redirect(), find_duplicate(), and same_phi_alternatives().

Referenced by find_clusters().

static void find_duplicate ( )
static
static void find_same_succ ( )
static
Find bbs with same successors.   

References find_same_succ_bb(), same_succ_def::remove(), and same_succ_alloc().

Referenced by init_worklist().

static bool gimple_equal_p ( )
static
static void gsi_advance_bw_nondebug_nonlocal ( gimple_stmt_iterator gsi,
tree vuse,
bool *  vuse_escaped 
)
static
Let GSI skip backwards over local defs.  Return the earliest vuse in VUSE.
   Return true in VUSE_ESCAPED if the vuse influenced a SSA_OP_DEF of one of the
   processed statements.   

References gimple_vuse(), gsi_end_p(), gsi_prev_nondebug(), gsi_stmt(), and stmt_local_def().

Referenced by find_duplicate().

static void gsi_advance_fw_nondebug_nonlocal ( )
static
Let GSI skip forwards over local defs.   

References gsi_end_p(), gsi_next_nondebug(), gsi_stmt(), and stmt_local_def().

Referenced by same_succ_def::equal().

static bool gvn_uses_equal ( )
static
VAL1 and VAL2 are either:
   - uses in BB1 and BB2, or
   - phi alternatives for BB1 and BB2.
   Return true if the uses have the same gvn value.   

References vn_valueize().

Referenced by gimple_equal_p(), and same_phi_alternatives_1().

static void init_worklist ( )
static
static bool inverse_flags ( )
static
Returns true if E1 and E2 have 2 successors, and if the successor flags
   are inverse for the EDGE_TRUE_VALUE and EDGE_FALSE_VALUE flags, and equal for
   the other edge flags.   

References same_succ_def::succ_flags.

Referenced by same_succ_def::equal(), and find_same_succ_bb().

static void mark_basic_block_deleted ( )
static
Mark BB as deleted, and mark its predecessors.   

References bitmap_set_bit(), basic_block_def::index, basic_block_def::preds, and edge_def::src.

Referenced by replace_block_by().

static void merge_clusters ( )
static
Merge cluster C2 into C1.   

References bb_cluster_def::bbs, bitmap_ior_into(), and bb_cluster_def::preds.

Referenced by set_cluster().

static bb_cluster new_cluster ( )
static
Allocate and init new cluster.   

References bb_cluster_def::bbs, bb_cluster_def::preds, and bb_cluster_def::rep_bb.

Referenced by set_cluster().

static void print_cluster ( )
static
Prints cluster C to FILE.   

References bb_cluster_def::bbs, bitmap_print(), and bb_cluster_def::preds.

Referenced by debug_cluster().

static void print_worklist ( )
static
Prints worklist to FILE.   

References same_succ_print().

Referenced by init_worklist().

static void release_last_vdef ( )
static
static void replace_block_by ( )
static
static void reset_cluster_vectors ( )
static
Reset all cluster vectors.   

References delete_cluster().

Referenced by tail_merge_optimize().

static bool same_phi_alternatives ( )
static
Returns whether for all successors of BB1 and BB2 (members of SAME_SUCC), the
   phi alternatives for BB1 and BB2 are equal.   

References find_edge(), edge_def::flags, same_phi_alternatives_1(), and same_succ_def::succs.

Referenced by find_clusters_1().

static bool same_phi_alternatives_1 ( )
static
Returns whether for all phis in DEST the phi alternatives for E1 and
   E2 are equal.   

References edge_def::dest_idx, gimple_phi_arg_def(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), gvn_uses_equal(), operand_equal_for_phi_arg_p(), and virtual_operand_p().

Referenced by same_phi_alternatives().

static same_succ same_succ_alloc ( )
static
static void same_succ_flush_bb ( )
static
static void same_succ_flush_bbs ( )
static
Removes all bbs in BBS from their corresponding same_succ.   

References same_succ_flush_bb().

Referenced by update_worklist().

static void same_succ_print ( )
static
static void same_succ_reset ( )
static
static void set_cluster ( )
static
Register equivalence of BB1 and BB2 (members of cluster C).  Store c in
   all_clusters, or merge c with existing cluster.   

References add_bb_to_cluster(), bb_cluster_def::bbs, delete_cluster(), bb_cluster_def::index, merge_clusters(), new_cluster(), bb_cluster_def::rep_bb, and update_rep_bb().

Referenced by find_duplicate().

int ssa_same_succ_print_traverse ( )
inline
Prints same_succ VE to VFILE.   

References same_succ_print().

Referenced by debug_same_succ().

static bool stmt_local_def ( )
static
Returns true if the only effect a statement STMT has, is to define locally
   used SSA_NAMEs.   

References gimple_bb(), gimple_has_side_effects(), and is_gimple_debug().

Referenced by gsi_advance_bw_nondebug_nonlocal(), gsi_advance_fw_nondebug_nonlocal(), and same_succ_hash().

static void stmt_update_dep_bb ( )
static
Update BB_DEP_BB, given the dependencies in STMT.   

References update_dep_bb().

Referenced by same_succ_hash().

static void update_debug_stmt ( )
static
Resets debug statement STMT if it has uses that are not dominated by their
   defs.   

References CDI_DOMINATORS, dominated_by_p(), gimple_bb(), gimple_debug_bind_p(), gimple_debug_bind_reset_value(), and update_stmt().

Referenced by update_debug_stmts().

static void update_debug_stmts ( )
static
Resets all debug statements that have uses that are not
   dominated by their defs.   

References gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), is_gimple_debug(), and update_debug_stmt().

Referenced by tail_merge_optimize().

static void update_dep_bb ( )
static
Update BB_DEP_BB (USE_BB), given a use of VAL in USE_BB.   

References CDI_DOMINATORS, dominated_by_p(), and gimple_bb().

Referenced by same_succ_hash(), and stmt_update_dep_bb().

static void update_rep_bb ( )
static
Update C->rep_bb, given that BB is added to the cluster.   

References CDI_DOMINATORS, dominated_by_p(), and bb_cluster_def::rep_bb.

Referenced by add_bb_to_cluster(), and set_cluster().

static void update_worklist ( )
static
static gimple vop_phi ( )
static
Returns the vop phi of BB, if any.   

References gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_phis(), gsi_stmt(), and virtual_operand_p().

Referenced by replace_block_by().


Variable Documentation

vec<bb_cluster> all_clusters
static
Array that contains all clusters.   
bitmap deleted_bb_preds
static
Bitmap that is used to mark predecessors of bbs that are
   deleted.   
bitmap deleted_bbs
static
Bitmap that is used to mark bbs that are recently deleted.   
int* same_succ_edge_flags
static
Array that is used to store the edge flags for a successor.   

Referenced by delete_worklist(), find_same_succ_bb(), and init_worklist().

hash_table<same_succ_def> same_succ_htab
static
bitmap update_bbs
static
Bbs for which update_debug_stmt need to be called.   
vec<same_succ> worklist
static
Vector of bbs to process.