GCC Middle and Back End API Reference
tree-ssa-pre.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "rtl.h"
#include "tree.h"
#include "gimple.h"
#include "predict.h"
#include "alloc-pool.h"
#include "tree-pass.h"
#include "ssa.h"
#include "cgraph.h"
#include "gimple-pretty-print.h"
#include "fold-const.h"
#include "cfganal.h"
#include "gimple-iterator.h"
#include "gimple-fold.h"
#include "tree-eh.h"
#include "gimplify.h"
#include "tree-cfg.h"
#include "tree-into-ssa.h"
#include "tree-dfa.h"
#include "tree-ssa.h"
#include "cfgloop.h"
#include "tree-ssa-sccvn.h"
#include "tree-scalar-evolution.h"
#include "dbgcnt.h"
#include "domwalk.h"
#include "tree-ssa-propagate.h"
#include "tree-ssa-dce.h"
#include "tree-cfgcleanup.h"
#include "alias.h"
#include "gimple-range.h"
Include dependency graph for tree-ssa-pre.cc:

Data Structures

union  pre_expr_union
 
struct  pre_expr_d
 
class  bitmap_set
 
struct  expr_pred_trans_d
 
struct  bb_bitmap_sets
 

Macros

#define PRE_EXPR_NAME(e)
 
#define PRE_EXPR_NARY(e)
 
#define PRE_EXPR_REFERENCE(e)
 
#define PRE_EXPR_CONSTANT(e)
 
#define FOR_EACH_EXPR_ID_IN_SET(set, id, bi)
 
#define FOR_EACH_VALUE_ID_IN_SET(set, id, bi)
 
#define EXP_GEN(BB)
 
#define PHI_GEN(BB)
 
#define TMP_GEN(BB)
 
#define AVAIL_OUT(BB)
 
#define ANTIC_IN(BB)
 
#define PA_IN(BB)
 
#define NEW_SETS(BB)
 
#define EXPR_DIES(BB)
 
#define PHI_TRANS_TABLE(BB)
 
#define BB_VISITED(BB)
 
#define BB_MAY_NOTRETURN(BB)
 
#define BB_LIVE_VOP_ON_EXIT(BB)
 

Typedefs

typedef pre_expr_dpre_expr
 
typedef class bitmap_setbitmap_set_t
 
typedef expr_pred_trans_dexpr_pred_trans_t
 
typedef const struct expr_pred_trans_dconst_expr_pred_trans_t
 
typedef struct bb_bitmap_setsbb_value_sets_t
 

Enumerations

enum  pre_expr_kind { NAME , NARY , REFERENCE , CONSTANT }
 

Functions

static unsigned int alloc_expression_id (pre_expr expr)
 
static unsigned int get_expression_id (const pre_expr expr)
 
static unsigned int lookup_expression_id (const pre_expr expr)
 
static pre_expr expression_for_id (unsigned int id)
 
static pre_expr get_or_alloc_expr_for_name (tree name)
 
static pre_expr get_or_alloc_expr_for_nary (vn_nary_op_t nary, unsigned value_id, location_t loc=UNKNOWN_LOCATION)
 
static pre_expr get_or_alloc_expr_for_reference (vn_reference_t reference, location_t loc=UNKNOWN_LOCATION)
 
static pre_expr bitmap_find_leader (bitmap_set_t, unsigned int)
 
static void bitmap_value_insert_into_set (bitmap_set_t, pre_expr)
 
static bool 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 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 bool phi_trans_add (expr_pred_trans_t *entry, pre_expr e, basic_block pred)
 
static void add_to_value (unsigned int v, pre_expr e)
 
static tree vn_valnum_from_value_id (unsigned int val)
 
static void bitmap_set_free (bitmap_set_t set)
 
static void pre_expr_DFS (pre_expr expr, bitmap_set_t set, bitmap val_visited, vec< pre_expr > &post)
 
static void pre_expr_DFS (unsigned val, bitmap_set_t set, bitmap val_visited, vec< pre_expr > &post)
 
static vec< pre_exprsorted_array_from_bitmap_set (bitmap_set_t set)
 
static bitmap_set_t bitmap_set_subtract_expressions (bitmap_set_t dest, bitmap_set_t orig)
 
static void bitmap_set_subtract_values (bitmap_set_t a, bitmap_set_t b)
 
static bool bitmap_set_equal (bitmap_set_t a, bitmap_set_t b)
 
static void print_pre_expr (FILE *outfile, const pre_expr expr)
 
void debug_pre_expr (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)
 
void debug_bitmap_sets_for (basic_block)
 
static void print_value_expressions (FILE *outfile, unsigned int val)
 
DEBUG_FUNCTION void debug_value_expressions (unsigned int val)
 
static pre_expr get_or_alloc_expr_for_constant (tree constant)
 
static pre_expr fully_constant_expression (pre_expr e)
 
static tree translate_vuse_through_block (vec< vn_reference_op_s > operands, alias_set_type set, alias_set_type base_set, tree type, tree vuse, edge e, bool *same_valid)
 
static pre_expr find_leader_in_sets (unsigned int val, bitmap_set_t set1, bitmap_set_t set2, bitmap_set_t set3=NULL)
 
static tree get_expr_type (const pre_expr e)
 
static tree get_representative_for (const pre_expr e, basic_block b=NULL)
 
static pre_expr phi_translate (bitmap_set_t, pre_expr, bitmap_set_t, bitmap_set_t, edge)
 
static pre_expr phi_translate_1 (bitmap_set_t dest, pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, edge e)
 
static void phi_translate_set (bitmap_set_t dest, bitmap_set_t set, edge e)
 
static bool value_dies_in_block_x (pre_expr expr, basic_block block)
 
static bool op_valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, tree op)
 
static bool valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, pre_expr expr)
 
static void clean (bitmap_set_t set1, bitmap_set_t set2=NULL)
 
static void prune_clobbered_mems (bitmap_set_t set, basic_block block, bool clean_traps)
 
static bool compute_antic_aux (basic_block block, bool block_has_abnormal_pred_edge)
 
static void compute_partial_antic_aux (basic_block block, bool block_has_abnormal_pred_edge)
 
static void compute_antic (void)
 
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 bool insert_into_preds_of_block (basic_block block, unsigned int exprnum, vec< pre_expr > &avail)
 
static bool do_pre_regular_insertion (basic_block block, basic_block dom, vec< pre_expr > exprs)
 
static bool do_pre_partial_partial_insertion (basic_block block, basic_block dom, vec< pre_expr > exprs)
 
static bool do_hoist_insertion (basic_block block)
 
static void insert (void)
 
static void compute_avail (function *fun)
 
static void init_pre (void)
 
static void fini_pre ()
 
gimple_opt_passmake_pass_pre (gcc::context *ctxt)
 

Variables

static unsigned int next_expression_id
 
static vec< pre_exprexpressions
 
static hash_table< pre_expr_d > * expression_to_id
 
static vec< unsigned > name_to_id
 
static obstack pre_expr_obstack
 
static object_allocator< pre_expr_dpre_expr_pool ("pre_expr nodes")
 
static vec< bitmapvalue_expressions
 
static vec< pre_exprconstant_value_expressions
 
struct { 
 
   int   insertions 
 
   int   pa_insert 
 
   int   hoist_insert 
 
   int   phis 
 
pre_stats 
 
static bool do_partial_partial
 
static object_allocator< bitmap_setbitmap_set_pool ("Bitmap sets")
 
static bitmap_obstack grand_bitmap_obstack
 
static bitmap inserted_exprs
 

Macro Definition Documentation

◆ ANTIC_IN

◆ AVAIL_OUT

◆ BB_LIVE_VOP_ON_EXIT

#define BB_LIVE_VOP_ON_EXIT ( BB)
Value:
((bb_value_sets_t) ((BB)->aux))->vop_on_exit

Referenced by compute_avail(), create_expression_by_pieces(), and translate_vuse_through_block().

◆ BB_MAY_NOTRETURN

#define BB_MAY_NOTRETURN ( BB)
Value:
((bb_value_sets_t) ((BB)->aux))->contains_may_not_return_call

Referenced by compute_avail(), and prune_clobbered_mems().

◆ BB_VISITED

◆ EXP_GEN

#define EXP_GEN ( BB)
Value:
((bb_value_sets_t) ((BB)->aux))->exp_gen

Referenced by compute_antic_aux(), compute_avail(), debug_bitmap_sets_for(), and init_pre().

◆ EXPR_DIES

#define EXPR_DIES ( BB)
Value:
((bb_value_sets_t) ((BB)->aux))->expr_dies

Referenced by value_dies_in_block_x().

◆ FOR_EACH_EXPR_ID_IN_SET

#define FOR_EACH_EXPR_ID_IN_SET ( set,
id,
bi )
Value:
#define EXECUTE_IF_SET_IN_BITMAP(BITMAP, MIN, BITNUM, ITER)
Definition bitmap.h:920
Definition cse.cc:4127
static vec< pre_expr > expressions
Definition tree-ssa-pre.cc:323

Referenced by bitmap_set_subtract_expressions(), bitmap_set_subtract_values(), clean(), compute_antic_aux(), compute_partial_antic_aux(), insert(), phi_translate_set(), print_bitmap_set(), and prune_clobbered_mems().

◆ FOR_EACH_VALUE_ID_IN_SET

#define FOR_EACH_VALUE_ID_IN_SET ( set,
id,
bi )
Value:
EXECUTE_IF_SET_IN_BITMAP (&(set)->values, 0, (id), (bi))

Referenced by sorted_array_from_bitmap_set().

◆ NEW_SETS

◆ PA_IN

◆ PHI_GEN

◆ PHI_TRANS_TABLE

#define PHI_TRANS_TABLE ( BB)
Value:
((bb_value_sets_t) ((BB)->aux))->phi_translate_table

Referenced by fini_pre(), init_pre(), phi_trans_add(), phi_translate(), and phi_translate_set().

◆ PRE_EXPR_CONSTANT

◆ PRE_EXPR_NAME

◆ PRE_EXPR_NARY

◆ PRE_EXPR_REFERENCE

◆ TMP_GEN

#define TMP_GEN ( BB)

Typedef Documentation

◆ bb_value_sets_t

typedef struct bb_bitmap_sets * bb_value_sets_t
Sets that we need to keep track of.   

◆ bitmap_set_t

typedef class bitmap_set * bitmap_set_t
An unordered bitmap set.  One bitmap tracks values, the other,
expressions.   

◆ const_expr_pred_trans_t

◆ expr_pred_trans_t

A three tuple {e, pred, v} used to cache phi translations in the
phi_translate_table.   

◆ pre_expr

typedef pre_expr_d * pre_expr

Enumeration Type Documentation

◆ pre_expr_kind

Full and partial redundancy elimination and code hoisting on SSA GIMPLE.
   Copyright (C) 2001-2024 Free Software Foundation, Inc.
   Contributed by Daniel Berlin <dan@dberlin.org> and Steven Bosscher
   <stevenb@suse.de>

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/>.   
Even though this file is called tree-ssa-pre.cc, we actually
  implement a bit more than just PRE here.  All of them piggy-back
  on GVN which is implemented in tree-ssa-sccvn.cc.

    1. Full Redundancy Elimination (FRE)
       This is the elimination phase of GVN.

    2. Partial Redundancy Elimination (PRE)
       This is adds computation of AVAIL_OUT and ANTIC_IN and
       doing expression insertion to form GVN-PRE.

    3. Code hoisting
       This optimization uses the ANTIC_IN sets computed for PRE
       to move expressions further up than PRE would do, to make
       multiple computations of the same value fully redundant.
       This pass is explained below (after the explanation of the
       basic algorithm for PRE).
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.
     Currently the AVAIL_OUT sets are the remaining quadraticness in
     memory of GVN-PRE.
  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 for Partial Redundancy Elimination:

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.

When optimizing for size, we only eliminate the partial redundancy
if we need to insert in only one predecessor.  This avoids almost
completely the code size increase that PRE usually causes.

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.

do_pre_regular_insertion/do_pre_partial_partial_insertion
performs these steps, driven by insert/insert_aux.

Fourth, we eliminate fully redundant expressions.
This is a simple statement walk that replaces redundant
calculations with the now available values.   
Basic algorithm for Code Hoisting:

Code hoisting is: Moving value computations up in the control flow
graph to make multiple copies redundant.  Typically this is a size
optimization, but there are cases where it also is helpful for speed.

A simple code hoisting algorithm is implemented that piggy-backs on
the PRE infrastructure.  For code hoisting, we have to know ANTIC_OUT
which is effectively ANTIC_IN - AVAIL_OUT.  The latter two have to be
computed for PRE, and we can use them to perform a limited version of
code hoisting, too.

For the purpose of this implementation, a value is hoistable to a basic
block B if the following properties are met:

1. The value is in ANTIC_IN(B) -- the value will be computed on all
   paths from B to function exit and it can be computed in B);

2. The value is not in AVAIL_OUT(B) -- there would be no need to
   compute the value again and make it available twice;

3. All successors of B are dominated by B -- makes sure that inserting
   a computation of the value in B will make the remaining
   computations fully redundant;

4. At least one successor has the value in AVAIL_OUT -- to avoid
   hoisting values up too far;

5. There are at least two successors of B -- hoisting in straight
   line code is pointless.

The third condition is not strictly necessary, but it would complicate
the hoisting pass a lot.  In fact, I don't know of any code hoisting
algorithm that does not have this requirement.  Fortunately, experiments
have show that most candidate hoistable values are in regions that meet
this condition (e.g. diamond-shape regions).

The forth condition is necessary to avoid hoisting things up too far
away from the uses of the value.  Nothing else limits the algorithm
from hoisting everything up as far as ANTIC_IN allows.  Experiments
with SPEC and CSiBE have shown that hoisting up too far results in more
spilling, less benefits for code size, and worse benchmark scores.
Fortunately, in practice most of the interesting hoisting opportunities
are caught despite this limitation.

For hoistable values that meet all conditions, expressions are inserted
to make the calculation of the hoistable value fully redundant.  We
perform code hoisting insertions after each round of PRE insertions,
because code hoisting never exposes new PRE opportunities, but PRE can
create new code hoisting opportunities.

The code hoisting algorithm is implemented in do_hoist_insert, driven
by insert/insert_aux.   
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

◆ add_to_value()

◆ alloc_expression_id()

◆ bitmap_find_leader()

static pre_expr bitmap_find_leader ( bitmap_set_t set,
unsigned int val )
static
Find the leader for a value (i.e., the name representing that
value) in a given set, and return it.  Return NULL if no leader
is found.   

References bitmap_bit_p, bitmap_set_contains_value(), constant_value_expressions, EXECUTE_IF_AND_IN_BITMAP, EXECUTE_IF_SET_IN_BITMAP, expression_for_id(), i, NULL, value_expressions, and value_id_constant_p().

Referenced by clean(), do_pre_partial_partial_insertion(), do_pre_regular_insertion(), find_leader_in_sets(), and find_or_generate_expression().

◆ bitmap_insert_into_set()

static void bitmap_insert_into_set ( bitmap_set_t set,
pre_expr expr )
static

◆ bitmap_set_contains_value()

static bool bitmap_set_contains_value ( bitmap_set_t set,
unsigned int value_id )
static

◆ bitmap_set_copy()

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

References bitmap_copy().

Referenced by compute_avail(), and phi_translate_set().

◆ bitmap_set_equal()

static bool bitmap_set_equal ( bitmap_set_t a,
bitmap_set_t b )
static
Return true if two bitmap sets are equal.   

References a, b, and bitmap_equal_p().

Referenced by compute_antic_aux().

◆ bitmap_set_free()

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

References bitmap_clear().

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

◆ bitmap_set_new()

static bitmap_set_t bitmap_set_new ( void )
static

◆ bitmap_set_subtract_expressions()

static bitmap_set_t bitmap_set_subtract_expressions ( bitmap_set_t dest,
bitmap_set_t orig )
static
Subtract all expressions contained in ORIG from DEST.   

References bitmap_and_compl(), bitmap_set_bit, bitmap_set_new(), expression_for_id(), FOR_EACH_EXPR_ID_IN_SET, get_expr_value_id(), and i.

Referenced by compute_antic_aux(), and compute_partial_antic_aux().

◆ bitmap_set_subtract_values()

static void bitmap_set_subtract_values ( bitmap_set_t a,
bitmap_set_t b )
static
Subtract all values in bitmap set B from bitmap set A.   

References a, b, bitmap_and_compl_into(), bitmap_bit_p, bitmap_clear_bit(), expression_for_id(), FOR_EACH_EXPR_ID_IN_SET, get_expr_value_id(), and i.

Referenced by compute_partial_antic_aux().

◆ bitmap_value_insert_into_set()

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

References bitmap_set_bit, gcc_checking_assert, get_expr_value_id(), get_expression_id(), and value_id_constant_p().

Referenced by compute_avail(), and compute_partial_antic_aux().

◆ bitmap_value_replace_in_set()

static bool bitmap_value_replace_in_set ( bitmap_set_t set,
pre_expr expr )
static

◆ clean()

static void clean ( bitmap_set_t set1,
bitmap_set_t set2 = NULL )
static
Clean the set of expressions SET1 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.   

References bitmap_clear_bit(), bitmap_find_leader(), expr, expression_for_id(), exprs, FOR_EACH_EXPR_ID_IN_SET, FOR_EACH_VEC_ELT, gcc_assert, get_expr_value_id(), get_expression_id(), i, sorted_array_from_bitmap_set(), and valid_in_sets().

Referenced by compute_antic(), and compute_partial_antic_aux().

◆ compute_antic()

◆ compute_antic_aux()

static bool compute_antic_aux ( basic_block block,
bool block_has_abnormal_pred_edge )
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])

Note that clean() is deferred until after the iteration.   

References ANTIC_IN, BB_VISITED, bitmap_and_into(), bitmap_bit_p, bitmap_clear_bit(), bitmap_ior_into(), bitmap_set_equal(), bitmap_set_free(), bitmap_set_new(), bitmap_set_subtract_expressions(), changed, dump_file, dump_flags, EDGE_COUNT, EXP_GEN, expression_for_id(), expressions, FOR_EACH_EDGE, FOR_EACH_EXPR_ID_IN_SET, FOR_EACH_VEC_ELT, gcc_assert, get_expr_value_id(), gimple_seq_empty_p(), i, basic_block_def::index, NULL, phi_nodes(), phi_translate_set(), print_bitmap_set(), prune_clobbered_mems(), S, single_succ_edge(), single_succ_p(), basic_block_def::succs, TDF_DETAILS, TMP_GEN, pre_expr_d::value_id, and worklist.

Referenced by compute_antic().

◆ compute_avail()

static void compute_avail ( function * fun)
static
Compute the AVAIL set for all basic blocks.

This function performs value numbering of the statements in each basic
block.  The AVAIL sets are built from information we glean while doing
this value numbering, since the AVAIL sets contain only one entry per
value.

AVAIL_IN[BLOCK] = AVAIL_OUT[dom(BLOCK)].
AVAIL_OUT[BLOCK] = AVAIL_IN[BLOCK] U PHI_GEN[BLOCK] U TMP_GEN[BLOCK].   

References add_to_value(), alias_set_subset_of(), ao_ref_alias_set(), ao_ref_base_alias_set(), ao_ref_init(), as_a(), AVAIL_OUT, vn_reference_s::base_set, BB_LIVE_VOP_ON_EXIT, BB_MAY_NOTRETURN, bitmap_insert_into_set(), bitmap_set_copy(), bitmap_value_insert_into_set(), build_aligned_type(), CDI_DOMINATORS, dump_file, dump_flags, ECF_CONST, ECF_LOOPING_CONST_OR_PURE, ECF_PURE, ENTRY_BLOCK, ENTRY_BLOCK_PTR_FOR_FN, EXP_GEN, first_dom_son(), FOR_EACH_SSA_NAME, FOR_EACH_SSA_TREE_OPERAND, free(), get_expr_value_id(), get_immediate_dominator(), get_or_alloc_expr_for_name(), get_or_alloc_expr_for_nary(), get_or_alloc_expr_for_reference(), gimple_assign_rhs1(), gimple_assign_rhs_code(), gimple_bb(), gimple_call_flags(), gimple_has_side_effects(), gimple_location(), gimple_nop_p(), gimple_phi_result(), gimple_vdef(), gimple_vop(), gimple_vuse(), gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_start_phis(), gsi_stmt(), has_zero_uses(), i, basic_block_def::index, init_vn_nary_op_from_stmt(), is_gimple_call(), is_gimple_debug(), n_basic_blocks_for_fn, next_dom_son(), NULL, vn_reference_op_struct::op0, vn_reference_op_struct::op2, vn_reference_op_struct::opcode, operand_equal_p(), vn_reference_s::operands, PHI_GEN, vn_nary_op_s::predicated_values, print_bitmap_set(), ptr_type_node, reference_alias_ptr_type(), vn_reference_s::result, vn_reference_s::set, sizeof_vn_nary_op(), ssa_default_def(), SSA_NAME_DEF_STMT, SSA_NAME_IS_DEFAULT_DEF, SSA_OP_DEF, SSA_OP_USE, ssa_undefined_value_p(), stmt_can_throw_external(), stmt_could_throw_p(), stmt_ends_bb_p(), stmt_may_clobber_ref_p(), TDF_DETAILS, TMP_GEN, wi::to_wide(), TREE_TYPE, vn_reference_op_struct::type, TYPE_ALIGN, TYPE_SIZE, pre_expr_d::value_id, vn_nary_op_s::value_id, value_id_constant_p(), virtual_operand_p(), vn_context_bb, vn_get_stmt_kind(), VN_NARY, vn_nary_length_from_stmt(), vn_nary_may_trap(), vn_nary_op_lookup_stmt(), VN_REFERENCE, vn_reference_lookup_call(), vn_reference_lookup_pieces(), vn_reference_may_trap(), vn_reference_operands_for_lookup(), VN_WALK, wide_int_to_tree(), and worklist.

◆ compute_partial_antic_aux()

static void 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] = clean(PA_OUT[BLOCK] - TMP_GEN[BLOCK] - ANTIC_IN[BLOCK])

References ANTIC_IN, bitmap_count_bits(), bitmap_ior_into(), bitmap_set_free(), bitmap_set_new(), bitmap_set_subtract_expressions(), bitmap_set_subtract_values(), bitmap_value_insert_into_set(), clean(), dump_file, dump_flags, EDGE_COUNT, expression_for_id(), expressions, FOR_EACH_EDGE, FOR_EACH_EXPR_ID_IN_SET, FOR_EACH_VEC_ELT, gimple_seq_empty_p(), i, basic_block_def::index, NULL, PA_IN, PHI_GEN, phi_nodes(), phi_translate_set(), print_bitmap_set(), prune_clobbered_mems(), single_succ(), single_succ_edge(), single_succ_p(), basic_block_def::succs, TDF_DETAILS, TMP_GEN, and worklist.

Referenced by compute_antic().

◆ create_component_ref_by_pieces()

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().

◆ create_component_ref_by_pieces_1()

◆ 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(), AVAIL_OUT, BB_LIVE_VOP_ON_EXIT, bitmap_set_bit, bitmap_value_replace_in_set(), build_constructor(), vn_reference_op_struct::clique, CONSTANT, CONSTRUCTOR_APPEND_ELT, create_component_ref_by_pieces(), create_component_ref_by_pieces_1(), dump_file, dump_flags, find_or_generate_expression(), fold_convert, fold_stmt_inplace(), gcc_assert, gcc_unreachable, get_expr_type(), get_expr_value_id(), get_next_value_id(), get_or_alloc_expr_for_name(), get_ptr_info(), gimple_build(), gimple_build_assign(), gimple_build_call_internal_vec(), gimple_build_call_vec(), gimple_call_builtin_p(), gimple_call_set_chain(), gimple_call_set_fntype(), gimple_call_set_lhs(), gimple_convert(), gimple_get_lhs(), gimple_seq_add_seq(), gimple_seq_add_stmt_without_update(), gimple_seq_discard(), gimple_seq_empty_p(), gimple_set_location(), gimple_set_vuse(), gsi_end_p(), gsi_last(), gsi_next(), gsi_prev(), gsi_start(), gsi_stmt(), i, basic_block_def::index, inserted_exprs, is_gimple_min_invariant(), vn_nary_op_s::length, make_ssa_name(), make_temp_ssa_name(), NAME, NARY, NEW_SETS, NULL, NULL_TREE, vn_nary_op_s::op, vn_reference_op_struct::op0, vn_reference_op_struct::op1, vn_nary_op_s::opcode, vn_reference_s::operands, PRE_EXPR_CONSTANT, PRE_EXPR_NAME, PRE_EXPR_NARY, PRE_EXPR_REFERENCE, pre_stats, print_gimple_stmt(), REFERENCE, sc, set_ptr_info_alignment(), sizetype, SSA_NAME_OCCURS_IN_ABNORMAL_PHI, SSA_NAME_VERSION, TDF_DETAILS, TREE_CODE, tree_fits_uhwi_p(), tree_to_uhwi(), TREE_TYPE, type(), vn_nary_op_s::type, vn_reference_op_struct::type, vn_reference_s::type, update_stmt(), useless_type_conversion_p(), vn_ssa_aux::valnum, pre_expr_d::value_id, vn_ssa_aux::value_id, VN_INFO(), and vn_valnum_from_value_id().

Referenced by do_hoist_insertion(), find_or_generate_expression(), and insert_into_preds_of_block().

◆ debug_bitmap_set()

DEBUG_FUNCTION void debug_bitmap_set ( bitmap_set_t set)

References print_bitmap_set().

◆ debug_bitmap_sets_for()

◆ debug_pre_expr()

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

References print_pre_expr().

◆ debug_value_expressions()

DEBUG_FUNCTION void debug_value_expressions ( unsigned int val)

◆ do_hoist_insertion()

◆ do_pre_partial_partial_insertion()

static bool do_pre_partial_partial_insertion ( basic_block block,
basic_block dom,
vec< pre_expr > exprs )
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 ANTIC_IN, AVAIL_OUT, bitmap_find_leader(), bitmap_set_contains_value(), dbg_cnt(), dump_file, dump_flags, EDGE_COUNT, expr, exprs, FOR_EACH_EDGE, FOR_EACH_VEC_ELT, gcc_assert, get_expr_value_id(), get_expression_id(), i, insert_into_preds_of_block(), NARY, NULL, optimize_edge_for_speed_p(), PA_IN, PHI_GEN, phi_translate(), pre_stats, basic_block_def::preds, print_pre_expr(), REFERENCE, basic_block_def::succs, and TDF_DETAILS.

Referenced by insert().

◆ do_pre_regular_insertion()

static bool do_pre_regular_insertion ( basic_block block,
basic_block dom,
vec< pre_expr > exprs )
static
Perform insertion of partially redundant or hoistable 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.
  If the block has multiple successors,
      3a. Iterate over the ANTIC values for the block to see if
          any of them are good candidates for hoisting.
      3b. If so, insert expressions computing the values in BLOCK,
          and add the new expressions into the NEW_SETS set.
  4. Recursively call ourselves on the dominator children of BLOCK.

  Steps 1, 2a, and 4 are done by insert_aux. 2b, 2c and 2d are done by
  do_pre_regular_insertion and do_partial_insertion.  3a and 3b are
  done in do_hoist_insertion.

References add_to_value(), ANTIC_IN, AVAIL_OUT, bitmap_find_leader(), bitmap_insert_into_set(), bitmap_set_bit, bitmap_set_contains_value(), bitmap_value_replace_in_set(), CONSTANT, dbg_cnt(), dump_file, dump_flags, EDGE_COUNT, pre_expr_d::equal(), expr, exprs, FOR_EACH_EDGE, FOR_EACH_VEC_ELT, gcc_assert, get_expr_type(), get_expr_value_id(), get_expression_id(), get_or_alloc_expr_for_name(), gimple_build_assign(), gsi_after_labels(), gsi_insert_before(), GSI_NEW_STMT, i, insert_into_preds_of_block(), inserted_exprs, pre_expr_d::kind, make_temp_ssa_name(), NAME, NARY, NEW_SETS, NULL, NULL_TREE, optimize_edge_for_speed_p(), PHI_GEN, phi_translate(), PRE_EXPR_CONSTANT, PRE_EXPR_NAME, basic_block_def::preds, print_pre_expr(), REFERENCE, SSA_NAME_OCCURS_IN_ABNORMAL_PHI, SSA_NAME_VERSION, TDF_DETAILS, vn_ssa_aux::valnum, vn_ssa_aux::value_id, VN_INFO(), and vn_valnum_from_value_id().

Referenced by insert().

◆ expression_for_id()

◆ find_leader_in_sets()

static pre_expr find_leader_in_sets ( unsigned int val,
bitmap_set_t set1,
bitmap_set_t set2,
bitmap_set_t set3 = NULL )
inlinestatic
Like bitmap_find_leader, but checks for the value existing in SET1 *or*
SET2 *or* SET3.  This is used to avoid making a set consisting of the union
of PA_IN and ANTIC_IN during insert and phi-translation.   

References bitmap_find_leader(), and NULL.

Referenced by phi_translate_1().

◆ find_or_generate_expression()

static tree find_or_generate_expression ( basic_block block,
tree op,
gimple_seq * stmts )
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 AVAIL_OUT, bitmap_find_leader(), CONSTANT, create_expression_by_pieces(), EXECUTE_IF_SET_IN_BITMAP, expression_for_id(), gcc_assert, i, is_gimple_min_invariant(), pre_expr_d::kind, NAME, NARY, NULL_TREE, PRE_EXPR_CONSTANT, PRE_EXPR_NAME, TREE_CODE, TREE_TYPE, vn_ssa_aux::valnum, value_expressions, vn_ssa_aux::value_id, value_id_constant_p(), and VN_INFO().

Referenced by create_component_ref_by_pieces_1(), and create_expression_by_pieces().

◆ fini_pre()

◆ fully_constant_expression()

static pre_expr fully_constant_expression ( pre_expr e)
static
Return the folded version of T if T, when folded, is a gimple
min_invariant or an SSA name.  Otherwise, return T.   

References CONSTANT, fully_constant_vn_reference_p(), get_or_alloc_expr_for_constant(), get_or_alloc_expr_for_name(), is_gimple_min_invariant(), pre_expr_d::kind, NARY, PRE_EXPR_NARY, PRE_EXPR_REFERENCE, REFERENCE, TREE_CODE, and vn_nary_simplify().

Referenced by phi_translate_1().

◆ get_expr_type()

◆ get_expr_value_id()

◆ get_expression_id()

◆ get_or_alloc_expr_for_constant()

static pre_expr get_or_alloc_expr_for_constant ( tree constant)
static

◆ get_or_alloc_expr_for_name()

◆ get_or_alloc_expr_for_nary()

static pre_expr get_or_alloc_expr_for_nary ( vn_nary_op_t nary,
unsigned value_id,
location_t loc = UNKNOWN_LOCATION )
static
Given an NARY, get or create a pre_expr to represent it.  Assign
VALUE_ID to it or allocate a new value-id if it is zero.  Record
LOC as the original location of the expression.   

References alloc_expression_id(), alloc_vn_nary_op_noinit(), expression_for_id(), gcc_assert, get_next_value_id(), vn_nary_op_s::hashcode, vn_nary_op_s::length, pre_expr_d::loc, lookup_expression_id(), NARY, PRE_EXPR_NARY, pre_expr_obstack, pre_expr_pool, sizeof_vn_nary_op(), pre_expr_d::value_id, value_id_constant_p(), and vn_nary_op_compute_hash().

Referenced by compute_avail(), and phi_translate_1().

◆ get_or_alloc_expr_for_reference()

static pre_expr get_or_alloc_expr_for_reference ( vn_reference_t reference,
location_t loc = UNKNOWN_LOCATION )
static
Given an REFERENCE, get or create a pre_expr to represent it.   

References alloc_expression_id(), expression_for_id(), pre_expr_d::loc, lookup_expression_id(), pre_expr_pool, PRE_EXPR_REFERENCE, REFERENCE, and vn_reference_s::value_id.

Referenced by compute_avail(), and phi_translate_1().

◆ get_representative_for()

static tree get_representative_for ( const pre_expr e,
basic_block b = NULL )
static
Get a representative SSA_NAME for a given expression that is available in B.
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(), b, CDI_DOMINATORS, CONSTANT, dominated_by_p(), dump_file, dump_flags, EXECUTE_IF_SET_IN_BITMAP, expression_for_id(), exprs, get_expr_type(), get_expr_value_id(), get_or_alloc_expr_for_name(), gimple_bb(), gimple_build_nop(), gimple_nop_p(), i, pre_expr_d::kind, make_temp_ssa_name(), NAME, NARY, vn_ssa_aux::needs_insertion, NULL_TREE, PRE_EXPR_CONSTANT, PRE_EXPR_NAME, print_generic_expr(), print_pre_expr(), REFERENCE, SSA_NAME_DEF_STMT, TDF_DETAILS, vn_ssa_aux::valnum, value_expressions, pre_expr_d::value_id, vn_ssa_aux::value_id, vn_ssa_aux::visited, and VN_INFO().

Referenced by phi_translate_1().

◆ init_pre()

◆ insert()

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

References ANTIC_IN, AVAIL_OUT, BASIC_BLOCK_FOR_FN, bitmap_set_free(), bitmap_set_new(), bitmap_set_pool, bitmap_value_replace_in_set(), CDI_DOMINATORS, cfun, changed, do_hoist_insertion(), do_partial_partial, do_pre_partial_partial_insertion(), do_pre_regular_insertion(), dump_file, dump_flags, EDGE_COUNT, EXIT_BLOCK, expression_for_id(), exprs, FOR_ALL_BB_FN, FOR_EACH_EDGE, FOR_EACH_EXPR_ID_IN_SET, free(), get_immediate_dominator(), i, last_basic_block_for_fn, n_basic_blocks_for_fn, NEW_SETS, NULL, PA_IN, pre_and_rev_post_order_compute(), single_pred_p(), sorted_array_from_bitmap_set(), statistics_histogram_event(), basic_block_def::succs, and TDF_DETAILS.

Referenced by compute_insert_delete(), compute_rev_insert_delete(), cse_insn(), cselib_find_slot(), discover_iteration_bound_by_body_walk(), eliminate_redundant_computations(), find_AT_string(), find_AT_string_in_table(), hash_table< Descriptor, Lazy, Allocator >::find_slot(), hash_table< Descriptor, Lazy, Allocator >::find_slot_with_hash(), get_named_event_id(), get_odr_type(), modref_access_node::insert(), modref_tree< T >::insert(), insert_const_anchor(), insert_with_costs(), avail_exprs_stack::lookup_avail_expr(), lookup_descr_for_decl(), lookup_element_for_decl(), lookup_field_for_decl(), fwd_jt_path_registry::lookup_redirection_data(), lookup_tramp_for_decl(), modref_tree< T >::merge(), merge_equiv_classes(), pre_edge_insert(), pre_edge_lcm(), pre_edge_lcm_avs(), pre_edge_rev_lcm(), record_jump_cond(), fibonacci_heap< K, V >::replace_key_data(), variable_from_dropped(), and vn_nary_build_or_lookup_1().

◆ insert_into_preds_of_block()

static bool insert_into_preds_of_block ( basic_block block,
unsigned int exprnum,
vec< pre_expr > & avail )
static
Insert the to-be-made-available values of expression EXPRNUM for each
predecessor, stored in AVAIL, into the predecessors of BLOCK, and
merge the result with a phi node, given the same value number as
NODE.  Return true if we have inserted new stuff.   

References add_phi_arg(), add_to_value(), AVAIL_OUT, bb_loop_depth(), bitmap_insert_into_set(), bitmap_set_bit, bitmap_value_replace_in_set(), CDI_DOMINATORS, cfun, CONSTANT, CONVERT_EXPR_CODE_P, create_expression_by_pieces(), create_phi_node(), dominated_by_p(), dump_file, dump_flags, EDGE_COUNT, EDGE_PRED, expression_for_id(), flow_bb_inside_loop_p(), FOR_EACH_EDGE, gcc_assert, get_expr_type(), get_expr_value_id(), get_or_alloc_expr_for_constant(), get_or_alloc_expr_for_name(), get_range_query(), gimple_bb(), gimple_seq_empty_p(), gsi_insert_seq_on_edge_immediate(), basic_block_def::index, inserted_exprs, insertions, INTEGRAL_TYPE_P, is_gimple_min_invariant(), pre_expr_d::kind, basic_block_def::loop_father, make_temp_ssa_name(), NARY, wi::neg_p(), NEW_SETS, NULL, NULL_TREE, PHI_GEN, PRE_EXPR_CONSTANT, PRE_EXPR_NAME, pre_stats, basic_block_def::preds, print_gimple_stmt(), r, range_cast(), REFERENCE, set_range_info(), SIGNED, SSA_NAME_DEF_STMT, SSA_NAME_RANGE_INFO, SSA_NAME_VERSION, TDF_DETAILS, TREE_CODE, TREE_TYPE, TYPE_PRECISION, UNKNOWN_LOCATION, unshare_expr(), useless_type_conversion_p(), vn_ssa_aux::valnum, vn_ssa_aux::value_id, VN_INFO(), and vn_valnum_from_value_id().

Referenced by do_pre_partial_partial_insertion(), and do_pre_regular_insertion().

◆ lookup_expression_id()

◆ make_pass_pre()

gimple_opt_pass * make_pass_pre ( gcc::context * ctxt)

◆ op_valid_in_sets()

static bool op_valid_in_sets ( bitmap_set_t set1,
bitmap_set_t set2,
tree op )
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(), TREE_CODE, pre_expr_d::value_id, vn_ssa_aux::value_id, and VN_INFO().

Referenced by valid_in_sets().

◆ phi_trans_add()

static bool phi_trans_add ( expr_pred_trans_t * entry,
pre_expr e,
basic_block pred )
inlinestatic
Add the tuple mapping from {expression E, basic block PRED} to
the phi translation table and return whether it pre-existed.   

References expr_pred_trans_d::e, get_expression_id(), and PHI_TRANS_TABLE.

Referenced by phi_translate().

◆ phi_translate()

◆ phi_translate_1()

static pre_expr phi_translate_1 ( bitmap_set_t dest,
pre_expr expr,
bitmap_set_t set1,
bitmap_set_t set2,
edge e )
static
Translate EXPR using phis in PHIBLOCK, so that it has the values of
the phis in PRED.  Return NULL if we can't find a leader for each part
of the translated expression.   

References add_to_value(), AVAIL_OUT, vn_reference_op_struct::base, vn_reference_s::base_set, changed, vn_reference_op_struct::clique, CONSTANT, dump_file, dump_flags, expr, find_leader_in_sets(), fold_unary, fully_constant_expression(), gcc_checking_assert, gcc_unreachable, get_expr_value_id(), get_next_value_id(), get_or_alloc_expr_for_constant(), get_or_alloc_expr_for_name(), get_or_alloc_expr_for_nary(), get_or_alloc_expr_for_reference(), get_representative_for(), gimple_bb(), i, basic_block_def::index, is_gimple_min_invariant(), pre_expr_d::kind, vn_nary_op_s::length, vn_reference_s::max_size, NAME, NARY, NULL, NULL_TREE, vn_reference_s::offset, vn_nary_op_s::op, vn_reference_op_struct::op0, vn_reference_op_struct::op1, vn_reference_op_struct::op2, vn_nary_op_s::opcode, vn_reference_op_struct::opcode, vn_reference_s::operands, PHI_ARG_DEF, phi_translate(), PRE_EXPR_NAME, PRE_EXPR_NARY, PRE_EXPR_REFERENCE, vn_nary_op_s::predicated_values, print_pre_expr(), REFERENCE, vn_reference_s::set, sizeof_vn_nary_op(), SSA_NAME_DEF_STMT, TDF_DETAILS, translate_vuse_through_block(), TREE_CODE, TREE_TYPE, operand::type, type(), vn_nary_op_s::type, vn_reference_op_struct::type, vn_reference_s::type, useless_type_conversion_p(), pre_expr_d::value_id, vn_nary_op_s::value_id, vn_reference_s::value_id, vn_ssa_aux::value_id, VN_INFO(), vn_nary_op_lookup_pieces(), vn_reference_insert_pieces(), vn_reference_lookup_pieces(), VN_WALK, vNULL, and vn_reference_s::vuse.

Referenced by phi_translate().

◆ phi_translate_set()

static void phi_translate_set ( bitmap_set_t dest,
bitmap_set_t set,
edge e )
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_count_bits(), bitmap_insert_into_set(), bitmap_set_copy(), expression_for_id(), FOR_EACH_EXPR_ID_IN_SET, gimple_seq_empty_p(), i, NULL, phi_nodes(), PHI_TRANS_TABLE, and phi_translate().

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

◆ pre_expr_DFS() [1/2]

static void pre_expr_DFS ( pre_expr expr,
bitmap_set_t set,
bitmap val_visited,
vec< pre_expr > & post )
static
DFS walk EXPR to its operands with leaders in SET, collecting
expressions in SET in postorder into POST.   

References bitmap_bit_p, bitmap_set_bit, i, vn_nary_op_s::length, NARY, vn_nary_op_s::op, vn_reference_s::operands, pre_expr_DFS(), PRE_EXPR_NARY, PRE_EXPR_REFERENCE, REFERENCE, TREE_CODE, vn_ssa_aux::value_id, and VN_INFO().

Referenced by pre_expr_DFS(), pre_expr_DFS(), and sorted_array_from_bitmap_set().

◆ pre_expr_DFS() [2/2]

static void pre_expr_DFS ( unsigned val,
bitmap_set_t set,
bitmap val_visited,
vec< pre_expr > & post )
static
DFS walk leaders of VAL to their operands with leaders in SET, collecting
expressions in SET in postorder into POST.   

References bitmap_bit_p, EXECUTE_IF_AND_IN_BITMAP, EXECUTE_IF_SET_IN_BITMAP, expression_for_id(), i, pre_expr_DFS(), and value_expressions.

◆ print_bitmap_set()

static void print_bitmap_set ( FILE * outfile,
bitmap_set_t set,
const char * setname,
int blockindex )
static

◆ print_pre_expr()

◆ print_value_expressions()

static void print_value_expressions ( FILE * outfile,
unsigned int val )
static
Print out the expressions that have VAL to OUTFILE.   

References bitmap_set::expressions, print_bitmap_set(), and value_expressions.

Referenced by debug_value_expressions().

◆ prune_clobbered_mems()

static void prune_clobbered_mems ( bitmap_set_t set,
basic_block block,
bool clean_traps )
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.
When CLEAN_TRAPS is true remove all possibly trapping expressions.   

References BB_MAY_NOTRETURN, bitmap_clear(), bitmap_clear_bit(), bitmap_set_bit, CDI_DOMINATORS, dominated_by_p(), expression_for_id(), FOR_EACH_EXPR_ID_IN_SET, get_expr_value_id(), gimple_bb(), gimple_nop_p(), i, NARY, PRE_EXPR_NARY, PRE_EXPR_REFERENCE, REFERENCE, SSA_NAME_DEF_STMT, value_dies_in_block_x(), pre_expr_d::value_id, vn_nary_may_trap(), vn_reference_may_trap(), and vn_reference_s::vuse.

Referenced by compute_antic_aux(), and compute_partial_antic_aux().

◆ sorted_array_from_bitmap_set()

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

References bitmap_count_bits(), bitmap_set_bit, bitmap_tree_view(), FOR_EACH_VALUE_ID_IN_SET, grand_bitmap_obstack, i, and pre_expr_DFS().

Referenced by clean(), do_hoist_insertion(), and insert().

◆ translate_vuse_through_block()

static tree translate_vuse_through_block ( vec< vn_reference_op_s > operands,
alias_set_type set,
alias_set_type base_set,
tree type,
tree vuse,
edge e,
bool * same_valid )
static
Translate the VUSE backwards through phi nodes in E->dest, so that
it has the value it would have in E->src.  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(), BB_LIVE_VOP_ON_EXIT, BITMAP_FREE, CDI_DOMINATORS, dominated_by_p(), get_continuation_for_phi(), get_immediate_dominator(), get_virtual_phi(), gimple_bb(), gimple_nop_p(), NULL, NULL_TREE, PHI_ARG_DEF, SSA_NAME_DEF_STMT, and visited.

Referenced by phi_translate_1().

◆ valid_in_sets()

static bool valid_in_sets ( bitmap_set_t set1,
bitmap_set_t set2,
pre_expr expr )
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 FOR_EACH_VEC_ELT, gcc_unreachable, i, 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, PRE_EXPR_NARY, PRE_EXPR_REFERENCE, and REFERENCE.

Referenced by clean(), and do_hoist_insertion().

◆ value_dies_in_block_x()

static bool value_dies_in_block_x ( pre_expr expr,
basic_block block )
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::base, vn_reference_s::base_set, BITMAP_ALLOC, bitmap_bit_p, bitmap_set_bit, EXPR_DIES, get_expression_id(), gimple_vdef(), gimple_vuse(), grand_bitmap_obstack, gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), NULL_TREE, vn_reference_s::operands, PRE_EXPR_REFERENCE, vn_reference_s::set, stmt_may_clobber_ref_p_1(), and vn_reference_s::type.

Referenced by prune_clobbered_mems().

◆ vn_valnum_from_value_id()

static tree vn_valnum_from_value_id ( unsigned int val)
static

Variable Documentation

◆ bitmap_set_pool

object_allocator< bitmap_set > bitmap_set_pool("Bitmap sets") ( "Bitmap sets" )
static
We can add and remove elements and entries to and from sets
and hash tables, so we use alloc pools for them.   

Referenced by bitmap_set_new(), fini_pre(), and insert().

◆ constant_value_expressions

vec<pre_expr> constant_value_expressions
static
We just record a single expression for each constant value,
one of kind CONSTANT.   

Referenced by add_to_value(), bitmap_find_leader(), fini_pre(), init_pre(), and vn_valnum_from_value_id().

◆ do_partial_partial

bool do_partial_partial
static

◆ expression_to_id

◆ expressions

vec<pre_expr> expressions
static
Mapping from expression to id number we can use in bitmap sets.   

Referenced by alloc_expression_id(), compute_antic_aux(), compute_partial_antic_aux(), expression_for_id(), fini_pre(), and init_pre().

◆ grand_bitmap_obstack

◆ hoist_insert

int hoist_insert

◆ inserted_exprs

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.    

Referenced by create_expression_by_pieces(), do_pre_regular_insertion(), eliminate_with_rpo_vn(), init_pre(), insert_into_preds_of_block(), and move_stmt().

◆ insertions

int insertions

◆ name_to_id

vec<unsigned> name_to_id
static

◆ next_expression_id

unsigned int next_expression_id
static
Next global expression id number.   

Referenced by alloc_expression_id(), and init_pre().

◆ pa_insert

int pa_insert

◆ phis

◆ pre_expr_obstack

obstack pre_expr_obstack
static

◆ pre_expr_pool

◆ [struct]

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_hoist_insertion(), do_pre_partial_partial_insertion(), init_pre(), and insert_into_preds_of_block().

◆ value_expressions