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

Data Structures

union  pre_expr_union_d
struct  pre_expr_d
struct  bitmap_set
struct  bb_bitmap_sets
struct  expr_pred_trans_d

Typedefs

typedef union pre_expr_union_d pre_expr_union
typedef pre_expr_dpre_expr
typedef struct bitmap_setbitmap_set_t
typedef struct bb_bitmap_setsbb_value_sets_t
typedef expr_pred_trans_dexpr_pred_trans_t
typedef struct expr_pred_trans_dconst_expr_pred_trans_t

Enumerations

enum  pre_expr_kind { NAME, NARY, REFERENCE, CONSTANT }

Functions

static unsigned int alloc_expression_id ()
static unsigned int get_expression_id ()
static unsigned int lookup_expression_id ()
static unsigned int get_or_alloc_expression_id ()
static pre_expr expression_for_id ()
static void clear_expression_ids ()
static pre_expr get_or_alloc_expr_for_name ()
static pre_expr bitmap_find_leader (bitmap_set_t, unsigned int)
static void bitmap_value_insert_into_set (bitmap_set_t, pre_expr)
static void bitmap_value_replace_in_set (bitmap_set_t, pre_expr)
static void bitmap_set_copy (bitmap_set_t, bitmap_set_t)
static bool bitmap_set_contains_value (bitmap_set_t, unsigned int)
static void bitmap_insert_into_set (bitmap_set_t, pre_expr)
static void bitmap_insert_into_set_1 (bitmap_set_t, pre_expr, unsigned int, bool)
static bitmap_set_t bitmap_set_new (void)
static tree create_expression_by_pieces (basic_block, pre_expr, gimple_seq *, tree)
static tree find_or_generate_expression (basic_block, tree, gimple_seq *)
static unsigned int get_expr_value_id (pre_expr)
static pre_expr phi_trans_lookup ()
static void phi_trans_add ()
static void add_to_value ()
static unsigned int get_expr_value_id ()
static tree sccvn_valnum_from_value_id ()
static void bitmap_remove_from_set ()
static void bitmap_insert_into_set ()
static void bitmap_set_copy ()
static void bitmap_set_free ()
static vec< pre_exprsorted_array_from_bitmap_set ()
static void bitmap_set_and ()
static bitmap_set_t bitmap_set_subtract ()
static void bitmap_set_subtract_values ()
static bool bitmap_set_contains_value ()
static bool bitmap_set_contains_expr ()
static void bitmap_set_replace_value (bitmap_set_t set, unsigned int lookfor, const pre_expr expr)
static bool bitmap_set_equal ()
static void bitmap_value_replace_in_set ()
static void bitmap_value_insert_into_set ()
static void print_pre_expr ()
void debug_pre_expr (pre_expr)
DEBUG_FUNCTION void debug_pre_expr ()
static void print_bitmap_set (FILE *outfile, bitmap_set_t set, const char *setname, int blockindex)
void debug_bitmap_set (bitmap_set_t)
DEBUG_FUNCTION void debug_bitmap_set ()
void debug_bitmap_sets_for (basic_block)
DEBUG_FUNCTION void debug_bitmap_sets_for ()
static void print_value_expressions ()
DEBUG_FUNCTION void debug_value_expressions ()
static pre_expr get_or_alloc_expr_for_constant ()
static tree get_constant_for_value_id ()
static pre_expr get_or_alloc_expr_for ()
static pre_expr fully_constant_expression ()
static tree translate_vuse_through_block (vec< vn_reference_op_s > operands, alias_set_type set, tree type, tree vuse, basic_block phiblock, basic_block block, bool *same_valid)
static pre_expr find_leader_in_sets ()
static tree get_expr_type ()
static tree get_representative_for ()
static pre_expr phi_translate (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, basic_block pred, basic_block phiblock)
static pre_expr phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, basic_block pred, basic_block phiblock)
static void phi_translate_set (bitmap_set_t dest, bitmap_set_t set, basic_block pred, basic_block phiblock)
static pre_expr bitmap_find_leader ()
static bool value_dies_in_block_x ()
static bool op_valid_in_sets ()
static bool valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, pre_expr expr, basic_block block)
static void dependent_clean ()
static void clean ()
static void prune_clobbered_mems ()
static bool defer_or_phi_translate_block (bitmap_set_t dest, bitmap_set_t source, basic_block block, basic_block phiblock)
static bool compute_antic_aux ()
static bool compute_partial_antic_aux (basic_block block, bool block_has_abnormal_pred_edge)
static void compute_antic ()
static tree create_component_ref_by_pieces_1 (basic_block block, vn_reference_t ref, unsigned int *operand, gimple_seq *stmts)
static tree create_component_ref_by_pieces (basic_block block, vn_reference_t ref, gimple_seq *stmts)
static tree find_or_generate_expression ()
static bool inhibit_phi_insertion ()
static bool insert_into_preds_of_block (basic_block block, unsigned int exprnum, vec< pre_expr > avail)
static bool do_regular_insertion ()
static bool do_partial_partial_insertion ()
static bool insert_aux ()
static void insert ()
static void compute_avail ()
static tree eliminate_avail ()
static void eliminate_push_avail ()
static tree eliminate_insert ()
static void eliminate_bb ()
static void eliminate_leave_block ()
static unsigned int eliminate ()
static unsigned fini_eliminate ()
static gimple mark_operand_necessary ()
static void remove_dead_inserted_code ()
static void init_pre ()
static void fini_pre ()
static unsigned int do_pre ()
static bool gate_pre ()
gimple_opt_passmake_pass_pre ()
static unsigned int execute_fre ()
static bool gate_fre ()
gimple_opt_passmake_pass_fre ()

Variables

static unsigned int next_expression_id
static vec< pre_exprexpressions
static hash_table< pre_expr_dexpression_to_id
static vec< unsigned > name_to_id
static alloc_pool pre_expr_pool
static vec< bitmapvalue_expressions
static int * postorder
static int postorder_num
struct {
   int   eliminations
   int   insertions
   int   pa_insert
   int   phis
pre_stats
static bool do_partial_partial
static alloc_pool bitmap_set_pool
static bitmap_obstack grand_bitmap_obstack
static bitmap need_eh_cleanup
static bitmap need_ab_cleanup
static hash_table
< expr_pred_trans_d
phi_translate_table
static sbitmap has_abnormal_preds
static sbitmap changed_blocks
static bitmap inserted_exprs
static vec< gimpleel_to_remove
static vec< gimpleel_to_update
static unsigned int el_todo
static vec< treeel_avail
static vec< treeel_avail_stack

Typedef Documentation

typedef struct bb_bitmap_sets * bb_value_sets_t
Sets that we need to keep track of.   
typedef struct bitmap_set * bitmap_set_t
An unordered bitmap set.  One bitmap tracks values, the other,
   expressions.   
A three tuple {e, pred, v} used to cache phi translations in the
   phi_translate_table.   
typedef pre_expr_d * pre_expr

Enumeration Type Documentation

@verbatim SSA-PRE for trees.

Copyright (C) 2001-2013 Free Software Foundation, Inc. Contributed by Daniel Berlin dan@d.nosp@m.berl.nosp@m.in.or.nosp@m.g and Steven Bosscher steve.nosp@m.nb@s.nosp@m.use.d.nosp@m.e

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/.

TODO:

   1. Avail sets can be shared by making an avail_find_leader that
      walks up the dominator tree and looks in those avail sets.
      This might affect code optimality, it's unclear right now.
   2. Strength reduction can be performed by anticipating expressions
      we can repair later on.
   3. We can do back-substitution or smarter value numbering to catch
      commutative expressions split up over multiple statements.
For ease of terminology, "expression node" in the below refers to
   every expression node but GIMPLE_ASSIGN, because GIMPLE_ASSIGNs
   represent the actual statement containing the expressions we care about,
   and we cache the value number by putting it in the expression.   
Basic algorithm

   First we walk the statements to generate the AVAIL sets, the
   EXP_GEN sets, and the tmp_gen sets.  EXP_GEN sets represent the
   generation of values/expressions by a given block.  We use them
   when computing the ANTIC sets.  The AVAIL sets consist of
   SSA_NAME's that represent values, so we know what values are
   available in what blocks.  AVAIL is a forward dataflow problem.  In
   SSA, values are never killed, so we don't need a kill set, or a
   fixpoint iteration, in order to calculate the AVAIL sets.  In
   traditional parlance, AVAIL sets tell us the downsafety of the
   expressions/values.

   Next, we generate the ANTIC sets.  These sets represent the
   anticipatable expressions.  ANTIC is a backwards dataflow
   problem.  An expression is anticipatable in a given block if it could
   be generated in that block.  This means that if we had to perform
   an insertion in that block, of the value of that expression, we
   could.  Calculating the ANTIC sets requires phi translation of
   expressions, because the flow goes backwards through phis.  We must
   iterate to a fixpoint of the ANTIC sets, because we have a kill
   set.  Even in SSA form, values are not live over the entire
   function, only from their definition point onwards.  So we have to
   remove values from the ANTIC set once we go past the definition
   point of the leaders that make them up.
   compute_antic/compute_antic_aux performs this computation.

   Third, we perform insertions to make partially redundant
   expressions fully redundant.

   An expression is partially redundant (excluding partial
   anticipation) if:

   1. It is AVAIL in some, but not all, of the predecessors of a
      given block.
   2. It is ANTIC in all the predecessors.

   In order to make it fully redundant, we insert the expression into
   the predecessors where it is not available, but is ANTIC.

   For the partial anticipation case, we only perform insertion if it
   is partially anticipated in some block, and fully available in all
   of the predecessors.

   insert/insert_aux/do_regular_insertion/do_partial_partial_insertion
   performs these steps.

   Fourth, we eliminate fully redundant expressions.
   This is a simple statement walk that replaces redundant
   calculations with the now available values.   
Representations of value numbers:

   Value numbers are represented by a representative SSA_NAME.  We
   will create fake SSA_NAME's in situations where we need a
   representative but do not have one (because it is a complex
   expression).  In order to facilitate storing the value numbers in
   bitmaps, and keep the number of wasted SSA_NAME's down, we also
   associate a value_id with each value number, and create full blown
   ssa_name's only where we actually need them (IE in operands of
   existing expressions).

   Theoretically you could replace all the value_id's with
   SSA_NAME_VERSION, but this would allocate a large number of
   SSA_NAME's (which are each > 30 bytes) just to get a 4 byte number.
   It would also require an additional indirection at each point we
   use the value id.   
Representation of expressions on value numbers:

   Expressions consisting of value numbers are represented the same
   way as our VN internally represents them, with an additional
   "pre_expr" wrapping around them in order to facilitate storing all
   of the expressions in the same sets.   
Representation of sets:

   The dataflow sets do not need to be sorted in any particular order
   for the majority of their lifetime, are simply represented as two
   bitmaps, one that keeps track of values present in the set, and one
   that keeps track of expressions present in the set.

   When we need them in topological order, we produce it on demand by
   transforming the bitmap into an array and sorting it into topo
   order.   
Type of expression, used to know which member of the PRE_EXPR union
   is valid.   
Enumerator:
NAME 
NARY 
REFERENCE 
CONSTANT 

Function Documentation

static unsigned int alloc_expression_id ( )
inlinestatic
static pre_expr bitmap_find_leader ( )
static
Find the leader for a value (i.e., the name representing that
   value) in a given set, and return it.  If STMT is non-NULL it
   makes sure the defining statement for the leader dominates it.
   Return NULL if no leader is found.   

References bitmap_set_contains_value(), CONSTANT, expression_for_id(), pre_expr_d::kind, and value_id_constant_p().

static void bitmap_insert_into_set ( bitmap_set_t  ,
pre_expr   
)
static
static void bitmap_insert_into_set ( )
static
Insert an expression EXPR into a bitmapped set.   

References bitmap_insert_into_set_1(), and get_expr_value_id().

static void bitmap_insert_into_set_1 ( bitmap_set_t  set,
pre_expr  expr,
unsigned int  val,
bool  allow_constants 
)
static
static void bitmap_remove_from_set ( )
static
static void bitmap_set_and ( )
static
static bool bitmap_set_contains_expr ( )
inlinestatic
static bool bitmap_set_contains_value ( )
static
Return true if bitmapped set SET contains the value VALUE_ID.   

References bitmap_bit_p(), bitmap_empty_p(), and value_id_constant_p().

static void bitmap_set_copy ( bitmap_set_t  ,
bitmap_set_t   
)
static
static void bitmap_set_copy ( )
static
Copy a bitmapped set ORIG, into bitmapped set DEST.   

References bitmap_copy(), bitmap_set::expressions, and bitmap_set::values.

static bool bitmap_set_equal ( )
static
Return true if two bitmap sets are equal.   

References bitmap_equal_p(), and bitmap_set::values.

Referenced by compute_antic_aux(), and compute_partial_antic_aux().

static void bitmap_set_free ( )
static
Free memory used up by SET.   

References bitmap_clear().

Referenced by compute_antic_aux(), compute_partial_antic_aux(), and insert().

static bitmap_set_t bitmap_set_new ( )
static
static void bitmap_set_replace_value ( bitmap_set_t  set,
unsigned int  lookfor,
const pre_expr  expr 
)
static
Replace an instance of value LOOKFOR with expression EXPR in SET.   

References bitmap_clear_bit(), bitmap_set_bit(), bitmap_set_contains_value(), get_expression_id(), and value_id_constant_p().

Referenced by bitmap_value_replace_in_set().

static bitmap_set_t bitmap_set_subtract ( )
static
Subtract all values and expressions contained in ORIG from DEST.   

References bitmap_and_compl(), bitmap_set_bit(), bitmap_set_new(), expression_for_id(), bitmap_set::expressions, get_expr_value_id(), and bitmap_set::values.

Referenced by compute_antic_aux(), and compute_partial_antic_aux().

static void bitmap_set_subtract_values ( )
static
static void bitmap_value_insert_into_set ( bitmap_set_t  ,
pre_expr   
)
static
static void bitmap_value_insert_into_set ( )
static
Insert EXPR into SET if EXPR's value is not already present in
   SET.   

References bitmap_set_bit(), get_expr_value_id(), get_or_alloc_expression_id(), pre_expr_d::id, and value_id_constant_p().

static void bitmap_value_replace_in_set ( bitmap_set_t  ,
pre_expr   
)
static
static void bitmap_value_replace_in_set ( )
static
Replace an instance of EXPR's VALUE with EXPR in SET if it exists,
   and add it otherwise.   

References bitmap_insert_into_set(), bitmap_set_contains_value(), bitmap_set_replace_value(), and get_expr_value_id().

static void clean ( )
static
Clean the set of expressions that are no longer valid in SET.  This
   means expressions that are made up of values we have no leaders for
   in SET.   

References bitmap_remove_from_set(), exprs, sorted_array_from_bitmap_set(), and valid_in_sets().

Referenced by compute_antic_aux().

static void clear_expression_ids ( )
static
Free the expression id field in all of our expressions,
   and then destroy the expressions array.   

Referenced by do_pre().

static bool compute_antic_aux ( )
static
Compute the ANTIC set for BLOCK.

   If succs(BLOCK) > 1 then
     ANTIC_OUT[BLOCK] = intersection of ANTIC_IN[b] for all succ(BLOCK)
   else if succs(BLOCK) == 1 then
     ANTIC_OUT[BLOCK] = phi_translate (ANTIC_IN[succ(BLOCK)])

   ANTIC_IN[BLOCK] = clean(ANTIC_OUT[BLOCK] U EXP_GEN[BLOCK] - TMP_GEN[BLOCK])

References bitmap_clear_bit(), bitmap_set_and(), bitmap_set_bit(), bitmap_set_copy(), bitmap_set_equal(), bitmap_set_free(), bitmap_set_new(), bitmap_set_subtract(), bitmap_value_insert_into_set(), changed, clean(), defer_or_phi_translate_block(), edge_def::dest, dump_file, dump_flags, expression_for_id(), first, gimple_seq_empty_p(), basic_block_def::index, phi_nodes(), phi_translate_set(), basic_block_def::preds, print_bitmap_set(), prune_clobbered_mems(), single_succ(), single_succ_p(), edge_def::src, basic_block_def::succs, and worklist.

Referenced by compute_antic().

static bool compute_partial_antic_aux ( basic_block  block,
bool  block_has_abnormal_pred_edge 
)
static
Compute PARTIAL_ANTIC for BLOCK.

   If succs(BLOCK) > 1 then
     PA_OUT[BLOCK] = value wise union of PA_IN[b] + all ANTIC_IN not
     in ANTIC_OUT for all succ(BLOCK)
   else if succs(BLOCK) == 1 then
     PA_OUT[BLOCK] = phi_translate (PA_IN[succ(BLOCK)])

   PA_IN[BLOCK] = dependent_clean(PA_OUT[BLOCK] - TMP_GEN[BLOCK]
                                  - ANTIC_IN[BLOCK])

References bitmap_clear_bit(), bitmap_count_bits(), bitmap_ior_into(), bitmap_set_bit(), bitmap_set_equal(), bitmap_set_free(), bitmap_set_new(), bitmap_set_subtract(), bitmap_set_subtract_values(), bitmap_value_insert_into_set(), changed, dependent_clean(), edge_def::dest, dump_file, dump_flags, expression_for_id(), edge_def::flags, gimple_seq_empty_p(), basic_block_def::index, phi_nodes(), phi_translate_set(), basic_block_def::preds, print_bitmap_set(), prune_clobbered_mems(), single_succ(), single_succ_edge(), single_succ_p(), edge_def::src, basic_block_def::succs, and worklist.

Referenced by compute_antic().

static tree create_component_ref_by_pieces ( basic_block  block,
vn_reference_t  ref,
gimple_seq stmts 
)
static
For COMPONENT_REF's and ARRAY_REF's, we can't have any intermediates for the
   COMPONENT_REF or MEM_REF or ARRAY_REF portion, because we'd end up with
   trying to rename aggregates into ssa form directly, which is a no no.

   Thus, this routine doesn't create temporaries, it just builds a
   single access expression for the array, calling
   find_or_generate_expression to build the innermost pieces.

   This function is a subroutine of create_expression_by_pieces, and
   should not be called on it's own unless you really know what you
   are doing.   

References create_component_ref_by_pieces_1().

Referenced by create_expression_by_pieces().

static tree create_expression_by_pieces ( basic_block  block,
pre_expr  expr,
gimple_seq stmts,
tree  type 
)
static
Create an expression in pieces, so that we can handle very complex
   expressions that may be ANTIC, but not necessary GIMPLE.
   BLOCK is the basic block the expression will be inserted into,
   EXPR is the expression to insert (in value form)
   STMTS is a statement list to append the necessary insertions into.

   This function will die if we hit some value that shouldn't be
   ANTIC but is (IE there is no leader for it, or its components).
   The function returns NULL_TREE in case a different antic expression
   has to be inserted first.
   This function may also generate expressions that are themselves
   partially or fully redundant.  Those that are will be either made
   fully redundant during the next iteration of insert (for partially
   redundant ones), or eliminated by eliminate (for fully redundant
   ones).   

References add_to_value(), bitmap_set_bit(), bitmap_value_replace_in_set(), build_constructor(), CONSTANT, create_component_ref_by_pieces(), dump_file, dump_flags, find_or_generate_expression(), fold_stmt_inplace(), force_gimple_operand(), get_expr_type(), get_expr_value_id(), get_next_value_id(), get_or_alloc_expr_for_name(), gimple_get_lhs(), gimple_seq_add_seq(), gimple_seq_add_stmt(), gimple_set_plf(), gsi_end_p(), gsi_next(), gsi_stmt(), basic_block_def::index, pre_expr_d::kind, vn_nary_op_s::length, make_temp_ssa_name(), NAME, NARY, vn_nary_op_s::op, pre_stats, print_gimple_stmt(), REFERENCE, sccvn_valnum_from_value_id(), vn_nary_op_s::type, unshare_expr(), update_stmt(), useless_type_conversion_p(), vn_ssa_aux::valnum, vn_ssa_aux::value_id, VN_INFO(), and VN_INFO_GET().

Referenced by find_or_generate_expression(), and insert_into_preds_of_block().

void debug_bitmap_set ( bitmap_set_t  )
DEBUG_FUNCTION void debug_bitmap_set ( )

References print_bitmap_set().

void debug_bitmap_sets_for ( basic_block  )
DEBUG_FUNCTION void debug_bitmap_sets_for ( )
void debug_pre_expr ( pre_expr  )
DEBUG_FUNCTION void debug_pre_expr ( )
Like print_pre_expr but always prints to stderr.   

References print_pre_expr().

DEBUG_FUNCTION void debug_value_expressions ( )
static bool defer_or_phi_translate_block ( bitmap_set_t  dest,
bitmap_set_t  source,
basic_block  block,
basic_block  phiblock 
)
static
Decide whether to defer a block for a later iteration, or PHI
   translate SOURCE to DEST using phis in PHIBLOCK.  Return false if we
   should defer the block, and true if we processed it.   

References bitmap_set_bit(), basic_block_def::index, and phi_translate_set().

Referenced by compute_antic_aux().

static void dependent_clean ( )
static
Clean the set of expressions that are no longer valid in SET1 or
   SET2.  This means expressions that are made up of values we have no
   leaders for in SET1 or SET2.  This version is used for partial
   anticipation, which means it is not valid in either ANTIC_IN or
   PA_IN.   

References bitmap_remove_from_set(), exprs, sorted_array_from_bitmap_set(), and valid_in_sets().

Referenced by compute_partial_antic_aux().

static bool do_partial_partial_insertion ( )
static
Perform insertion for partially anticipatable expressions.  There
   is only one case we will perform insertion for these.  This case is
   if the expression is partially anticipatable, and fully available.
   In this case, we know that putting it earlier will enable us to
   remove the later computation.   

References bitmap_find_leader(), bitmap_set_contains_value(), dbg_cnt(), edge_def::dest, edge_def::dest_idx, dump_file, dump_flags, exprs, edge_def::flags, fully_constant_expression(), get_expr_value_id(), get_expression_id(), insert_into_preds_of_block(), pre_expr_d::kind, NARY, optimize_edge_for_speed_p(), phi_translate(), pre_stats, basic_block_def::preds, print_pre_expr(), REFERENCE, sorted_array_from_bitmap_set(), edge_def::src, basic_block_def::succs, and vNULL.

Referenced by insert_aux().

static bool do_regular_insertion ( )
static
Perform insertion of partially redundant values.
   For BLOCK, do the following:
   1.  Propagate the NEW_SETS of the dominator into the current block.
   If the block has multiple predecessors,
       2a. Iterate over the ANTIC expressions for the block to see if
           any of them are partially redundant.
       2b. If so, insert them into the necessary predecessors to make
           the expression fully redundant.
       2c. Insert a new PHI merging the values of the predecessors.
       2d. Insert the new PHI, and the new expressions, into the
           NEW_SETS set.
   3. Recursively call ourselves on the dominator children of BLOCK.

   Steps 1, 2a, and 3 are done by insert_aux. 2b, 2c and 2d are done by
   do_regular_insertion and do_partial_insertion.

References add_to_value(), bitmap_find_leader(), bitmap_insert_into_set(), bitmap_set_bit(), bitmap_set_contains_value(), bitmap_value_replace_in_set(), CONSTANT, dbg_cnt(), edge_def::dest_idx, dump_file, dump_flags, pre_expr_d::equal(), exprs, edge_def::flags, fully_constant_expression(), get_expr_type(), get_expr_value_id(), get_expression_id(), get_or_alloc_expr_for_name(), gimple_set_plf(), gsi_after_labels(), gsi_insert_before(), GSI_NEW_STMT, insert_into_preds_of_block(), pre_expr_d::kind, make_temp_ssa_name(), NAME, NARY, optimize_edge_for_speed_p(), phi_translate(), basic_block_def::preds, print_pre_expr(), REFERENCE, sccvn_valnum_from_value_id(), sorted_array_from_bitmap_set(), edge_def::src, vn_ssa_aux::valnum, vn_ssa_aux::value_id, VN_INFO(), VN_INFO_GET(), and vNULL.

Referenced by insert_aux().

static tree eliminate_avail ( )
static
Return a leader for OP that is available at the current point of the
   eliminate domwalk.   

References is_gimple_min_invariant(), vn_ssa_aux::valnum, and VN_INFO().

Referenced by eliminate_bb(), and eliminate_insert().

static tree eliminate_insert ( )
static
Insert the expression recorded by SCCVN for VAL at *GSI.  Returns
   the leader for the expression if insertion was successful.   

References dump_file, dump_flags, eliminate_avail(), gimple_set_plf(), gsi_insert_before(), GSI_SAME_STMT, make_temp_ssa_name(), pre_stats, print_gimple_stmt(), vn_ssa_aux::valnum, vn_get_expr_for(), and VN_INFO_GET().

Referenced by eliminate_bb().

static void eliminate_leave_block ( )
static
Make no longer available leaders no longer available.   

References VN_INFO().

Referenced by eliminate().

static void eliminate_push_avail ( )
static
At the current point of the eliminate domwalk make OP available.   

References vn_ssa_aux::valnum, and VN_INFO().

Referenced by eliminate_bb().

static unsigned int execute_fre ( )
static
static pre_expr find_leader_in_sets ( )
inlinestatic
Like bitmap_find_leader, but checks for the value existing in SET1 *or*
   SET2.  This is used to avoid making a set consisting of the union
   of PA_IN and ANTIC_IN during insert.   

References bitmap_find_leader().

Referenced by phi_translate_1().

static tree find_or_generate_expression ( basic_block  ,
tree  ,
gimple_seq  
)
static
static tree find_or_generate_expression ( )
static
Find a simple leader for an expression, or generate one using
   create_expression_by_pieces from a NARY expression for the value.
   BLOCK is the basic_block we are looking for leaders in.
   OP is the tree expression to find a leader for or generate.
   Returns the leader or NULL_TREE on failure.   

References bitmap_find_leader(), CONSTANT, create_expression_by_pieces(), expression_for_id(), get_expr_type(), get_expr_value_id(), get_or_alloc_expr_for(), pre_expr_d::kind, NAME, and NARY.

static unsigned fini_eliminate ( )
static
Perform CFG cleanups made necessary by elimination.   

References bitmap_empty_p(), gimple_purge_all_dead_abnormal_call_edges(), and gimple_purge_all_dead_eh_edges().

Referenced by do_pre(), and execute_fre().

static void fini_pre ( )
static
static bool gate_fre ( )
static
static bool gate_pre ( )
static
static tree get_constant_for_value_id ( )
static
Given a value id V, find the actual tree representing the constant
   value if there is one, and return it. Return NULL if we can't find
   a constant.   

References CONSTANT, expression_for_id(), pre_expr_d::kind, and value_id_constant_p().

Referenced by fully_constant_expression().

static tree get_expr_type ( )
static
static unsigned int get_expr_value_id ( )
static
Return the value id for a PRE expression EXPR.   

References CONSTANT, get_constant_value_id(), pre_expr_d::kind, NAME, NARY, REFERENCE, vn_ssa_aux::value_id, and VN_INFO().

static unsigned int get_expression_id ( )
inlinestatic
static pre_expr get_or_alloc_expr_for ( )
static
static pre_expr get_or_alloc_expr_for_constant ( )
static
static unsigned int get_or_alloc_expression_id ( )
inlinestatic
Return the existing expression id for EXPR, or create one if one
   does not exist yet.   

References alloc_expression_id(), pre_expr_d::id, and lookup_expression_id().

Referenced by add_to_value(), bitmap_insert_into_set_1(), bitmap_value_insert_into_set(), compute_avail(), and phi_translate_1().

static tree get_representative_for ( )
static
Get a representative SSA_NAME for a given expression.
   Since all of our sub-expressions are treated as values, we require
   them to be SSA_NAME's for simplicity.
   Prior versions of GVNPRE used to use "value handles" here, so that
   an expression would be VH.11 + VH.10 instead of d_3 + e_6.  In
   either case, the operands are really values (IE we do not expect
   them to be usable without finding leaders).   

References add_to_value(), CONSTANT, dump_file, dump_flags, expression_for_id(), exprs, get_expr_type(), get_expr_value_id(), get_or_alloc_expr_for_name(), gimple_build_nop(), pre_expr_d::kind, make_temp_ssa_name(), NAME, NARY, vn_ssa_aux::needs_insertion, print_generic_expr(), print_pre_expr(), REFERENCE, vn_ssa_aux::valnum, vn_ssa_aux::value_id, VN_INFO(), and VN_INFO_GET().

Referenced by phi_translate_1().

static bool inhibit_phi_insertion ( )
static
Returns true if we want to inhibit the insertions of PHI nodes
   for the given EXPR for basic block BB (a member of a loop).
   We want to do this, when we fear that the induction variable we
   create might inhibit vectorization.   

References flow_bb_inside_loop_p(), gimple_bb(), basic_block_def::loop_father, vn_reference_op_struct::op0, vn_reference_op_struct::opcode, vn_reference_s::operands, and simple_iv().

Referenced by insert_into_preds_of_block().

static void insert ( )
static
Perform insertion of partially redundant values.   

References bitmap_set_free(), bitmap_set_new(), cfun, dump_file, dump_flags, insert_aux(), and statistics_histogram_event().

Referenced by do_pre().

gimple_opt_pass* make_pass_fre ( )
gimple_opt_pass* make_pass_pre ( )
static gimple mark_operand_necessary ( )
inlinestatic
Borrow a bit of tree-ssa-dce.c for the moment.
   XXX: In 4.1, we should be able to just run a DCE pass after PRE, though
   this may be a bit faster, and we may want critical edges kept split.   
If OP's defining statement has not already been determined to be necessary,
   mark that statement necessary. Return the stmt, if it is newly
   necessary.   

References gimple_nop_p(), gimple_plf(), and gimple_set_plf().

Referenced by remove_dead_inserted_code().

static bool op_valid_in_sets ( )
static
Determine if OP is valid in SET1 U SET2, which it is when the union
   contains its value-id.   

References bitmap_set_contains_value(), vn_ssa_aux::value_id, and VN_INFO().

Referenced by valid_in_sets().

static void phi_trans_add ( )
inlinestatic
static pre_expr phi_trans_lookup ( )
inlinestatic
Search in the phi translation table for the translation of
   expression E in basic block PRED.
   Return the translated value, if found, NULL otherwise.   

References expr_pred_trans_d::e, hash_table< Descriptor, Allocator >::find_slot_with_hash(), pre_expr_d::hash(), expr_pred_trans_d::hashcode, basic_block_def::index, iterative_hash_hashval_t(), expr_pred_trans_d::pred, and expr_pred_trans_d::v.

Referenced by phi_translate().

static pre_expr phi_translate ( pre_expr  expr,
bitmap_set_t  set1,
bitmap_set_t  set2,
basic_block  pred,
basic_block  phiblock 
)
static
static pre_expr phi_translate_1 ( pre_expr  expr,
bitmap_set_t  set1,
bitmap_set_t  set2,
basic_block  pred,
basic_block  phiblock 
)
static
static void phi_translate_set ( bitmap_set_t  dest,
bitmap_set_t  set,
basic_block  pred,
basic_block  phiblock 
)
static
For each expression in SET, translate the values through phi nodes
   in PHIBLOCK using edge PHIBLOCK->PRED, and store the resulting
   expressions in DEST.   

References bitmap_set_copy(), bitmap_value_insert_into_set(), bitmap_value_replace_in_set(), exprs, gimple_seq_empty_p(), pre_expr_d::kind, NAME, phi_nodes(), phi_translate(), and sorted_array_from_bitmap_set().

Referenced by compute_antic_aux(), compute_partial_antic_aux(), and defer_or_phi_translate_block().

static void print_bitmap_set ( FILE *  outfile,
bitmap_set_t  set,
const char *  setname,
int  blockindex 
)
static
static void print_value_expressions ( )
static
Print out the expressions that have VAL to OUTFILE.   

References bitmap_set::expressions, and print_bitmap_set().

Referenced by debug_value_expressions().

static void prune_clobbered_mems ( )
static
Clean the set of expressions that are no longer valid in SET because
   they are clobbered in BLOCK or because they trap and may not be executed.   

References bitmap_remove_from_set(), CDI_DOMINATORS, dominated_by_p(), expression_for_id(), gimple_nop_p(), pre_expr_d::kind, NARY, REFERENCE, value_dies_in_block_x(), vn_nary_may_trap(), and vn_reference_s::vuse.

Referenced by compute_antic_aux(), and compute_partial_antic_aux().

static void remove_dead_inserted_code ( )
static
Because we don't follow exactly the standard PRE algorithm, and decide not
   to insert PHI nodes sometimes, and because value numbering of casts isn't
   perfect, we sometimes end up inserting dead code.   This simple DCE-like
   pass removes any insertions we made that weren't actually used.   

References bitmap_clear_bit(), bitmap_empty_p(), bitmap_first_set_bit(), bitmap_set_bit(), dump_file, dump_flags, gimple_phi_num_args(), gimple_plf(), gsi_for_stmt(), gsi_remove(), mark_operand_necessary(), print_gimple_stmt(), release_defs(), remove_phi_node(), and worklist.

Referenced by do_pre().

static tree sccvn_valnum_from_value_id ( )
static
Return a SCCVN valnum (SSA name or constant) for the PRE value-id VAL.   

References CONSTANT, expression_for_id(), pre_expr_d::kind, NAME, vn_ssa_aux::valnum, and VN_INFO().

Referenced by create_expression_by_pieces(), do_regular_insertion(), and insert_into_preds_of_block().

static vec<pre_expr> sorted_array_from_bitmap_set ( )
static
Generate an topological-ordered array of bitmap set SET.   

References bitmap_bit_p(), bitmap_count_bits(), and expression_for_id().

Referenced by clean(), dependent_clean(), do_partial_partial_insertion(), do_regular_insertion(), and phi_translate_set().

static tree translate_vuse_through_block ( vec< vn_reference_op_s operands,
alias_set_type  set,
tree  type,
tree  vuse,
basic_block  phiblock,
basic_block  block,
bool *  same_valid 
)
static
Translate the VUSE backwards through phi nodes in PHIBLOCK, so that
   it has the value it would have in BLOCK.  Set *SAME_VALID to true
   in case the new vuse doesn't change the value id of the OPERANDS.   

References ao_ref_init_from_vn_reference(), edge_def::dest_idx, find_edge(), get_continuation_for_phi(), gimple_vuse(), stmt_may_clobber_ref_p_1(), and visited.

Referenced by phi_translate_1().

static bool valid_in_sets ( bitmap_set_t  set1,
bitmap_set_t  set2,
pre_expr  expr,
basic_block  block 
)
static
Determine if the expression EXPR is valid in SET1 U SET2.
   ONLY SET2 CAN BE NULL.
   This means that we have a leader for each part of the expression
   (if it consists of values), or the expression is an SSA_NAME.
   For loads/calls, we also see if the vuse is killed in this block.   

References bitmap_find_leader(), get_expr_value_id(), pre_expr_d::kind, vn_nary_op_s::length, NAME, NARY, vn_nary_op_s::op, vn_reference_op_struct::op0, vn_reference_op_struct::op1, vn_reference_op_struct::op2, op_valid_in_sets(), vn_reference_s::operands, and REFERENCE.

Referenced by clean(), and dependent_clean().

static bool value_dies_in_block_x ( )
static
Determine if EXPR, a memory expression, is ANTIC_IN at the top of
   BLOCK by seeing if it is not killed in the block.  Note that we are
   only determining whether there is a store that kills it.  Because
   of the order in which clean iterates over values, we are guaranteed
   that altered operands will have caused us to be eliminated from the
   ANTIC_IN set already.   

References ao_ref_init_from_vn_reference(), ao_ref_s::base, bitmap_bit_p(), bitmap_set_bit(), get_expression_id(), gimple_vdef(), gimple_vuse(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), vn_reference_s::operands, vn_reference_s::set, stmt_may_clobber_ref_p_1(), and vn_reference_s::type.

Referenced by prune_clobbered_mems().


Variable Documentation

alloc_pool bitmap_set_pool
static
We can add and remove elements and entries to and from sets
   and hash tables, so we use alloc pools for them.   
sbitmap changed_blocks
static
List of blocks that may have changed during ANTIC computation and
   thus need to be iterated over.   
bool do_partial_partial
static
vec<tree> el_avail
static
vec<tree> el_avail_stack
static
vec<gimple> el_to_remove
static
Local state for the eliminate domwalk.   
vec<gimple> el_to_update
static
unsigned int el_todo
static

Referenced by eliminate(), and eliminate_bb().

int eliminations
hash_table<pre_expr_d> expression_to_id
static
vec<pre_expr> expressions
static
Mapping from expression to id number we can use in bitmap sets.   
bitmap_obstack grand_bitmap_obstack
static
sbitmap has_abnormal_preds
static
bitmap inserted_exprs
static
Inserted expressions are placed onto this worklist, which is used
   for performing quick dead code elimination of insertions we made
   that didn't turn out to be necessary.    
int insertions
vec<unsigned> name_to_id
static
bitmap need_ab_cleanup
static
Set of blocks with statements that have had their AB properties changed.   
bitmap need_eh_cleanup
static
Set of blocks with statements that have had their EH properties changed.   
unsigned int next_expression_id
static
Next global expression id number.   

Referenced by alloc_expression_id(), and init_pre().

int pa_insert
hash_table<expr_pred_trans_d> phi_translate_table
static
The phi_translate_table caches phi translations for a given
   expression and predecessor.   
int* postorder
static
Basic block list in postorder.   

Referenced by compute_antic(), fast_dce(), fini_pre(), graphds_domtree(), graphds_scc(), init_pre(), and walk_dominator_tree().

int postorder_num
static
alloc_pool pre_expr_pool
static
struct { ... } pre_stats
This structure is used to keep track of statistics on what
   optimization PRE was able to perform.   

Referenced by create_expression_by_pieces(), do_partial_partial_insertion(), do_pre(), eliminate_bb(), eliminate_insert(), execute_fre(), init_pre(), and insert_into_preds_of_block().

vec<bitmap> value_expressions
static
Mapping from value id to expressions with that value_id.