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

Data Structures

struct  prop_value_d


typedef struct prop_value_d prop_value_t


static bool stmt_may_generate_copy ()
static prop_value_tget_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_passmake_pass_copy_prop ()


static prop_value_tcopy_of
static unsigned n_copy_of

Typedef Documentation

typedef struct prop_value_d prop_value_t

Function Documentation

static enum ssa_prop_result copy_prop_visit_assignment ( )
   Evaluate the RHS of STMT.  If it produces a valid copy, set the LHS
   value and store the LHS into *RESULT_P.  
         Straight copy between two SSA names.  First, make sure that
         we can propagate the RHS into uses of LHS.  
static enum ssa_prop_result copy_prop_visit_cond_stmt ( )
   if it can determine which edge will be taken.  Otherwise, return
     The only conditionals that we may be able to compute statically
     are predicates involving two SSA_NAMEs.  
         See if we can determine the predicate's value.  
         We can fold COND and get a useful result only when we have
         the same SSA_NAME on both sides of a comparison operator.  

References dump_file, and print_gimple_stmt().

Referenced by copy_prop_visit_stmt().

static enum ssa_prop_result copy_prop_visit_phi_node ( )
   Visit PHI node PHI.  If all the arguments produce the same value,
   set it to be the value of the LHS of PHI.  
         We don't care about values flowing through non-executable
         Names that flow through abnormal edges cannot be used to
         derive copies.  
             If we didn't visit the definition of arg yet treat it as
             UNDEFINED.  This also handles PHI arguments that are the
             same as lhs.  We'll come here again.  
         Avoid copy propagation from an inner into an outer loop.
         Otherwise, this may move loop variant variables outside of
         their loops and prevent coalescing opportunities.  If the
         value was loop invariant, it will be hoisted by LICM and
         exposed for copy propagation.
         ???  The value will be always loop invariant.
         In loop-closed SSA form do not copy-propagate through
         PHI nodes in blocks with a loop exit edge predecessor.  
         If the LHS didn't have a value yet, make it a copy of the
         first argument we find.   
         If PHI_VAL and ARG don't have a common copy-of chain, then
         this PHI node cannot be a copy operation.  

References prop_value_d::value.

static enum ssa_prop_result copy_prop_visit_stmt ( )
   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
         If the statement is a copy assignment, evaluate its RHS to
         see if the lattice value of its output has changed.  
         See if we can determine which edge goes out of a conditional
         Any other kind of statement is not interesting for constant
         propagation and, therefore, not worth simulating.  
         The assignment is not a copy operation.  Don't visit this
         statement again and mark all the definitions in the statement
         to be copies of nothing.  

References copy_prop_visit_cond_stmt().

static void dump_copy_of ( )
   Dump the copy-of value for variable VAR to FILE.  
static unsigned int execute_copy_prop ( )
   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).  
static void fini_copy_prop ( )
   Deallocate memory used in copy propagation and do final
     Set the final copy-of value for each variable by traversing the
     copy-of chains.  
         In theory the points-to solution of all members of the
         copy chain is their intersection.  For now we do not bother
         to compute this but only make sure we do not lose points-to
         information completely by setting the points-to solution
         of the representative to the first solution we find if
         it doesn't have one already.  
     Don't do DCE if SCEV is initialized.  It would destroy the scev cache.  
static bool gate_copy_prop ( )
static prop_value_t* get_copy_of_val ( )
   Return the copy-of value for VAR.  
         If the variable will never generate a useful copy relation,
         make it its own copy.  
static tree get_value ( )
   Callback for substitute_and_fold to get at the final copy-of values.  

References copy_of, duplicate_ssa_name_ptr_info(), and duplicate_ssa_name_range_info().

static void init_copy_prop ( )
   Initialize structures used for copy propagation.  
             The only statements that we care about are those that may
             generate useful copies.  We also need to mark conditional
             jumps so that their outgoing edges are added to the work
             lists of the propagator.

             Avoid copy propagation from an inner into an outer loop.
             Otherwise, this may move loop variant variables outside of
             their loops and prevent coalescing opportunities.  If the
             value was loop invariant, it will be hoisted by LICM and
             exposed for copy propagation.
             ???  This doesn't make sense.  
                      Since we are iterating over the statements in
                      BB, not the phi nodes, STMT will always be an
             Mark all the outputs of this statement as not being
             the copy of anything.  
gimple_opt_pass* make_pass_copy_prop ( )
static bool set_copy_of_val ( )
   Set VAL to be the copy of VAR.  If that changed return true.  
     Set FIRST to be the first link in COPY_OF[DEST].  If that
     changed, return true.  
static bool stmt_may_generate_copy ( )
   Return true if this statement may generate a useful copy.  
     If the statement has volatile operands, it won't generate a
     useful copy.  
     Statements with loads and/or stores will never generate a useful copy.  
     Otherwise, the only statements that generate useful copies are
     assignments whose RHS is just an SSA name that doesn't flow
     through abnormal edges.  
static tree valueize_val ( )
   Return the variable VAR is a copy of or VAR if VAR isn't the result
   of a copy.  

References copy_of, operand_equal_p(), and prop_value_d::value.

Variable Documentation

prop_value_t* copy_of

Referenced by get_value(), and valueize_val().

unsigned n_copy_of