GCC Middle and Back End API 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"
Data Structures | |
struct | prop_value_t |
class | copy_prop |
class | copy_folder |
Functions | |
static bool | stmt_may_generate_copy (gimple *stmt) |
static prop_value_t * | get_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_pass * | make_pass_copy_prop (gcc::context *ctxt) |
Variables | |
static prop_value_t * | copy_of |
static unsigned | n_copy_of |
|
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().
|
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().
|
static |
Dump the copy-of value for variable VAR to FILE.
References copy_of, dump_flags, print_generic_expr(), SSA_NAME_VERSION, TREE_CODE, and prop_value_t::value.
Referenced by copy_prop::visit_phi().
|
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.
|
static |
Deallocate memory used in copy propagation and do final substitution.
References cfun, changed, copy_of, FOR_EACH_SSA_NAME, free(), free_numbers_of_iterations_estimates(), i, maybe_duplicate_ssa_info_at_copy(), scev_initialized_p(), scev_reset(), substitute_and_fold_engine::substitute_and_fold(), and TREE_CODE.
Referenced by execute_copy_prop().
|
inlinestatic |
Return the copy-of value for VAR.
References copy_of, NULL_TREE, SSA_NAME_DEF_STMT, SSA_NAME_VERSION, stmt_may_generate_copy(), and prop_value_t::value.
Referenced by valueize_val(), and copy_prop::visit_phi().
|
static |
Initialize structures used for copy propagation.
References cfun, copy_of, FOR_EACH_BB_FN, FOR_EACH_SSA_TREE_OPERAND, gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), n_copy_of, num_ssa_names, prop_set_simulate_again(), prop_simulate_again_p(), set_copy_of_val(), si, SSA_OP_ALL_DEFS, stmt_ends_bb_p(), stmt_may_generate_copy(), and virtual_operand_p().
Referenced by execute_copy_prop().
gimple_opt_pass * make_pass_copy_prop | ( | gcc::context * | ctxt | ) |
Set VAL to be the copy of VAR. If that changed return true.
References copy_of, operand_equal_p(), SSA_NAME_VERSION, and prop_value_t::value.
Referenced by copy_prop_visit_assignment(), init_copy_prop(), copy_prop::visit_phi(), and copy_prop::visit_stmt().
Return true if this statement may generate a useful copy.
References gimple_assign_rhs1(), gimple_assign_single_p(), gimple_has_volatile_ops(), gimple_phi_result(), gimple_vuse(), is_gimple_min_invariant(), single_ssa_tree_operand(), SSA_NAME_OCCURS_IN_ABNORMAL_PHI, and SSA_OP_USE.
Referenced by get_copy_of_val(), and init_copy_prop().
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().
|
static |
Referenced by dump_copy_of(), fini_copy_prop(), get_copy_of_val(), init_copy_prop(), set_copy_of_val(), and copy_folder::value_of_expr().
|
static |
Referenced by init_copy_prop(), and copy_folder::value_of_expr().