GCC Middle and Back End API Reference
tree-ssa-copy.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 "gimple-iterator.h"
#include "tree-cfg.h"
#include "tree-ssa-propagate.h"
#include "cfgloop.h"
#include "tree-scalar-evolution.h"
#include "tree-ssa-loop-niter.h"
#include "gimple-fold.h"
Include dependency graph for tree-ssa-copy.cc:

Data Structures

struct  prop_value_t
 
class  copy_prop
 
class  copy_folder
 

Functions

static bool stmt_may_generate_copy (gimple *stmt)
 
static prop_value_tget_copy_of_val (tree var)
 
static tree valueize_val (tree var)
 
static bool set_copy_of_val (tree var, tree val)
 
static void dump_copy_of (FILE *file, tree var)
 
static enum ssa_prop_result copy_prop_visit_assignment (gimple *stmt, tree *result_p)
 
static enum ssa_prop_result copy_prop_visit_cond_stmt (gimple *stmt, edge *taken_edge_p)
 
static void init_copy_prop (void)
 
static bool fini_copy_prop (void)
 
static unsigned int execute_copy_prop (void)
 
gimple_opt_passmake_pass_copy_prop (gcc::context *ctxt)
 

Variables

static prop_value_tcopy_of
 
static unsigned n_copy_of
 

Function Documentation

◆ copy_prop_visit_assignment()

static enum ssa_prop_result copy_prop_visit_assignment ( gimple * stmt,
tree * result_p )
static
Evaluate the RHS of STMT. If it produces a valid copy, set the LHS value and store the LHS into *RESULT_P.

References gimple_assign_lhs(), gimple_fold_stmt_to_constant_1(), is_gimple_min_invariant(), may_propagate_copy(), set_copy_of_val(), SSA_PROP_INTERESTING, SSA_PROP_NOT_INTERESTING, SSA_PROP_VARYING, TREE_CODE, and valueize_val().

Referenced by copy_prop::visit_stmt().

◆ copy_prop_visit_cond_stmt()

static enum ssa_prop_result copy_prop_visit_cond_stmt ( gimple * stmt,
edge * taken_edge_p )
static
Visit the GIMPLE_COND STMT. Return SSA_PROP_INTERESTING if it can determine which edge will be taken. Otherwise, return SSA_PROP_VARYING.

References boolean_type_node, dump_file, dump_flags, find_taken_edge(), fold_binary_loc(), gimple_bb(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_location(), print_gimple_stmt(), SSA_PROP_INTERESTING, SSA_PROP_VARYING, TDF_DETAILS, and valueize_val().

Referenced by copy_prop::visit_stmt().

◆ dump_copy_of()

static void dump_copy_of ( FILE * file,
tree var )
static
Dump the copy-of value for variable VAR to FILE.

References copy_of, dump_flags, print_generic_expr(), SSA_NAME_VERSION, and TREE_CODE.

Referenced by copy_prop::visit_phi().

◆ execute_copy_prop()

static unsigned int execute_copy_prop ( void )
static
Main entry point to the copy propagator. PHIS_ONLY is true if we should only consider PHI nodes as generating copy propagation opportunities. The algorithm propagates the value COPY-OF using ssa_propagate. For every variable X_i, COPY-OF(X_i) indicates which variable is X_i created from. The following example shows how the algorithm proceeds at a high level: 1 a_24 = x_1 2 a_2 = PHI <a_24, x_1> 3 a_5 = PHI <a_2> 4 x_1 = PHI <x_298, a_5, a_2> The end result should be that a_2, a_5, a_24 and x_1 are a copy of x_298. Propagation proceeds as follows. Visit #1: a_24 is copy-of x_1. Value changed. Visit #2: a_2 is copy-of x_1. Value changed. Visit #3: a_5 is copy-of x_1. Value changed. Visit #4: x_1 is copy-of x_298. Value changed. Visit #1: a_24 is copy-of x_298. Value changed. Visit #2: a_2 is copy-of x_298. Value changed. Visit #3: a_5 is copy-of x_298. Value changed. Visit #4: x_1 is copy-of x_298. Stable state reached. When visiting PHI nodes, we only consider arguments that flow through edges marked executable by the propagation engine. So, when visiting statement #2 for the first time, we will only look at the first argument (a_24) and optimistically assume that its value is the copy of a_24 (x_1).

References fini_copy_prop(), init_copy_prop(), ssa_propagation_engine::ssa_propagate(), and TODO_cleanup_cfg.

◆ fini_copy_prop()

static bool fini_copy_prop ( void )
static

◆ get_copy_of_val()

static prop_value_t * get_copy_of_val ( tree var)
inlinestatic

◆ init_copy_prop()

◆ make_pass_copy_prop()

gimple_opt_pass * make_pass_copy_prop ( gcc::context * ctxt)

◆ set_copy_of_val()

static bool set_copy_of_val ( tree var,
tree val )
inlinestatic
Set VAL to be the copy of VAR. If that changed return true.

References copy_of, operand_equal_p(), and SSA_NAME_VERSION.

Referenced by copy_prop_visit_assignment(), init_copy_prop(), copy_prop::visit_phi(), and copy_prop::visit_stmt().

◆ stmt_may_generate_copy()

static bool stmt_may_generate_copy ( gimple * stmt)
static

◆ valueize_val()

static tree valueize_val ( tree var)
inlinestatic
Return the variable VAR is a copy of or VAR if VAR isn't the result of a copy.

References get_copy_of_val(), TREE_CODE, and prop_value_t::value.

Referenced by copy_prop_visit_assignment(), copy_prop_visit_cond_stmt(), and copy_prop::visit_phi().

Variable Documentation

◆ copy_of

◆ n_copy_of

unsigned n_copy_of
static