GCC Middle and Back End API Reference
|
Data Structures | |
struct | prop_value_d |
Typedefs | |
typedef struct prop_value_d | prop_value_t |
Functions | |
bool | may_propagate_copy () |
bool | may_propagate_copy_into_stmt () |
bool | may_propagate_copy_into_asm () |
static void | replace_exp_1 (use_operand_p op_p, tree val, bool for_propagation) |
void | propagate_value () |
void | replace_exp () |
void | propagate_tree_value () |
void | propagate_tree_value_into_stmt () |
static bool | stmt_may_generate_copy () |
static prop_value_t * | get_copy_of_val () |
static tree | valueize_val () |
static bool | set_copy_of_val () |
static void | dump_copy_of () |
static enum ssa_prop_result | copy_prop_visit_assignment () |
static enum ssa_prop_result | copy_prop_visit_cond_stmt () |
static enum ssa_prop_result | copy_prop_visit_stmt () |
static enum ssa_prop_result | copy_prop_visit_phi_node () |
static void | init_copy_prop () |
static tree | get_value () |
static void | fini_copy_prop () |
static unsigned int | execute_copy_prop () |
static bool | gate_copy_prop () |
gimple_opt_pass * | make_pass_copy_prop () |
Variables | |
static prop_value_t * | copy_of |
static unsigned | n_copy_of |
typedef struct prop_value_d prop_value_t |
|
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_assign_rhs1(), may_propagate_copy(), set_copy_of_val(), SSA_PROP_INTERESTING, SSA_PROP_NOT_INTERESTING, SSA_PROP_VARYING, 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 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, and valueize_val().
Referenced by copy_prop_visit_stmt().
|
static |
Visit PHI node PHI. If all the arguments produce the same value, set it to be the value of the LHS of PHI.
References dump_copy_of(), dump_file, dump_flags, edge_def::flags, get_copy_of_val(), gimple_phi_arg_def(), gimple_phi_arg_edge(), gimple_phi_num_args(), gimple_phi_result(), LOOP_CLOSED_SSA, loop_depth_of_name(), loop_exit_edge_p(), basic_block_def::loop_father, loops_state_satisfies_p(), may_propagate_copy(), operand_equal_p(), print_gimple_stmt(), set_copy_of_val(), edge_def::src, SSA_PROP_INTERESTING, SSA_PROP_NOT_INTERESTING, SSA_PROP_VARYING, prop_value_d::value, and valueize_val().
Referenced by execute_copy_prop().
|
static |
Evaluate statement STMT. If the statement produces a new output value, return SSA_PROP_INTERESTING and store the SSA_NAME holding the new value in *RESULT_P. If STMT is a conditional branch and we can determine its truth value, set *TAKEN_EDGE_P accordingly. If the new value produced by STMT is varying, return SSA_PROP_VARYING.
References copy_prop_visit_assignment(), copy_prop_visit_cond_stmt(), dump_file, dump_flags, gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_single_p(), is_gimple_min_invariant(), print_gimple_stmt(), set_copy_of_val(), and SSA_PROP_VARYING.
Referenced by execute_copy_prop().
|
static |
Dump the copy-of value for variable VAR to FILE.
References dump_flags, print_generic_expr(), and prop_value_d::value.
Referenced by copy_prop_visit_phi_node().
|
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 copy_prop_visit_phi_node(), copy_prop_visit_stmt(), fini_copy_prop(), init_copy_prop(), and ssa_propagate().
|
static |
Deallocate memory used in copy propagation and do final substitution.
References duplicate_ssa_name_ptr_info(), free(), get_value(), scev_initialized_p(), substitute_and_fold(), and prop_value_d::value.
Referenced by execute_copy_prop().
|
static |
|
inlinestatic |
Return the copy-of value for VAR.
References stmt_may_generate_copy(), and prop_value_d::value.
Referenced by copy_prop_visit_phi_node(), and valueize_val().
|
static |
Callback for substitute_and_fold to get at the final copy-of values.
References n_copy_of, and prop_value_d::value.
Referenced by fini_copy_prop().
|
static |
Initialize structures used for copy propagation.
References bb_loop_depth(), gimple_assign_rhs1(), gimple_phi_result(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), loop_depth_of_name(), n_copy_of, prop_set_simulate_again(), prop_simulate_again_p(), set_copy_of_val(), si, stmt_ends_bb_p(), stmt_may_generate_copy(), and virtual_operand_p().
Referenced by execute_copy_prop().
gimple_opt_pass* make_pass_copy_prop | ( | ) |
bool may_propagate_copy | ( | ) |
@verbatim Copy propagation and SSA_NAME replacement support routines.
Copyright (C) 2004-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
This file implements the copy propagation pass and provides a handful of interfaces for performing const/copy propagation and simple expression replacement which keep variable annotations up-to-date. We require that for any copy operation where the RHS and LHS have a non-null memory tag the memory tag be the same. It is OK for one or both of the memory tags to be NULL. We also require tracking if a variable is dereferenced in a load or store operation. We enforce these requirements by having all copy propagation and replacements of one SSA_NAME with a different SSA_NAME to use the APIs defined in this file.
Return true if we may propagate ORIG into DEST, false otherwise.
References useless_type_conversion_p(), and virtual_operand_p().
bool may_propagate_copy_into_asm | ( | ) |
Similarly, but we know that we're propagating into an ASM_EXPR.
bool may_propagate_copy_into_stmt | ( | ) |
Like may_propagate_copy, but use as the destination expression the principal expression (typically, the RHS) contained in statement DEST. This is more efficient when working with the gimple tuples representation.
References gimple_assign_lhs(), gimple_assign_rhs1(), gimple_assign_single_p(), gimple_call_lhs(), gimple_switch_index(), is_gimple_assign(), is_gimple_call(), may_propagate_copy(), and useless_type_conversion_p().
void propagate_tree_value | ( | ) |
Propagate the value VAL (assumed to be a constant or another SSA_NAME) into the tree pointed to by OP_P. Use this version for const/copy propagation when SSA operands are not available. It will perform the additional checks to ensure validity of the const/copy propagation, but will not update any operand information. Be sure to mark the stmt as modified.
References may_propagate_copy(), and unshare_expr().
void propagate_tree_value_into_stmt | ( | ) |
Like propagate_tree_value, but use as the operand to replace the principal expression (typically, the RHS) contained in the statement referenced by iterator GSI. Note that it is not always possible to update the statement in-place, so a new statement may be created to replace the original.
References build_zero_cst(), gimple_assign_rhs1(), gimple_assign_set_rhs_from_tree(), gimple_assign_single_p(), gimple_call_lhs(), gimple_cond_set_code(), gimple_cond_set_lhs(), gimple_cond_set_rhs(), gimple_switch_index_ptr(), gsi_stmt(), is_gimple_assign(), is_gimple_call(), propagate_tree_value(), and update_call_from_tree().
void propagate_value | ( | ) |
Propagate the value VAL (assumed to be a constant or another SSA_NAME) into the operand pointed to by OP_P. Use this version for const/copy propagation as it will perform additional checks to ensure validity of the const/copy propagation.
References replace_exp_1().
void replace_exp | ( | ) |
Replace *OP_P with value VAL (assumed to be a constant or another SSA_NAME). Use this version when not const/copy propagating values. For example, PRE uses this version when building expressions as they would appear in specific blocks taking into account actions of PHI nodes. The statement in which an expression has been replaced should be folded using fold_stmt_inplace.
References replace_exp_1().
|
static |
Common code for propagate_value and replace_exp. Replace use operand OP_P with VAL. FOR_PROPAGATION indicates if the replacement is done to propagate a value or not.
References may_propagate_copy(), and unshare_expr().
Referenced by propagate_value(), and replace_exp().
|
inlinestatic |
Set VAL to be the copy of VAR. If that changed return true.
References operand_equal_p(), and prop_value_d::value.
Referenced by copy_prop_visit_assignment(), copy_prop_visit_phi_node(), copy_prop_visit_stmt(), and init_copy_prop().
|
static |
Return true if this statement may generate a useful copy.
References gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_has_volatile_ops(), gimple_phi_result(), gimple_vuse(), and is_gimple_min_invariant().
Referenced by get_copy_of_val(), and init_copy_prop().
|
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(), and prop_value_d::value.
Referenced by copy_prop_visit_assignment(), copy_prop_visit_cond_stmt(), and copy_prop_visit_phi_node().
|
static |
|
static |
Referenced by get_value(), and init_copy_prop().