GCC Middle and Back End API Reference
predicate Class Reference

#include <gimple-predicate-analysis.h>

Inheritance diagram for predicate:
Collaboration diagram for predicate:

Public Types

enum  op_type {
  OP_PREDICATE , OP_EXPR , OP_CAPTURE , OP_C_EXPR ,
  OP_IF , OP_WITH
}
 

Public Member Functions

 predicate (predicate_id *p_, location_t loc)
 
 predicate (bool empty_val)
 
 predicate (const predicate &rhs)
 
 ~predicate ()
 
predicateoperator= (const predicate &)
 
bool is_empty () const
 
bool is_true () const
 
bool is_false () const
 
bool empty_val () const
 
const pred_chain_union chain () const
 
void init_from_control_deps (const vec< edge > *, unsigned, bool)
 
void dump (FILE *) const
 
void dump (FILE *, gimple *, const char *) const
 
void debug () const
 
void normalize (gimple *=NULL, bool=false)
 
void simplify (gimple *=NULL, bool=false)
 
bool superset_of (const predicate &) const
 
virtual void gen_transform (FILE *, int, const char *, bool, int, const char *, capture_info *, dt_operand **=0, int=0)
 

Data Fields

predicate_idp
 
enum op_type type
 
location_t location
 

Private Member Functions

bool includes (const pred_chain &) const
 
void push_pred (const pred_info &)
 
void normalize (pred_chain *, pred_info, tree_code, pred_chain *, hash_set< tree > *)
 
void normalize (const pred_info &)
 
void normalize (const pred_chain &)
 
bool simplify_2 ()
 
bool simplify_3 ()
 
bool simplify_4 ()
 

Private Attributes

pred_chain_union m_preds
 
bool m_cval
 

Detailed Description

A predicate operand.  Predicates are leafs in the AST.   
Represents a complex Boolean predicate expression.   

Member Enumeration Documentation

◆ op_type

enum operand::op_type
inherited
Enumerator
OP_PREDICATE 
OP_EXPR 
OP_CAPTURE 
OP_C_EXPR 
OP_IF 
OP_WITH 

Constructor & Destructor Documentation

◆ predicate() [1/3]

predicate::predicate ( predicate_id * p_,
location_t loc )
inline

◆ predicate() [2/3]

predicate::predicate ( bool empty_val)
inline

◆ predicate() [3/3]

predicate::predicate ( const predicate & rhs)
inline

◆ ~predicate()

predicate::~predicate ( )
Release resources in *THIS.   

References i.

Member Function Documentation

◆ chain()

const pred_chain_union predicate::chain ( ) const
inline

References m_preds.

Referenced by uninit_analysis::overlap().

◆ debug()

void predicate::debug ( ) const
Dump predicates in *THIS to stderr.   

◆ dump() [1/2]

void predicate::dump ( FILE * f) const
Dump predicates in *THIS to F.   

References dump_pred_chain(), i, and chain::length.

◆ dump() [2/2]

void predicate::dump ( FILE * f,
gimple * stmt,
const char * msg ) const
Dump predicates in *THIS for STMT prepended by MSG to F.   

References fputc(), msg, and print_gimple_stmt().

◆ empty_val()

bool predicate::empty_val ( ) const
inline

References m_cval.

◆ gen_transform()

virtual void operand::gen_transform ( FILE * ,
int ,
const char * ,
bool ,
int ,
const char * ,
capture_info * ,
dt_operand ** = 0,
int = 0 )
inlinevirtualinherited

Reimplemented in c_expr, capture, and expr.

Referenced by capture::gen_transform().

◆ includes()

bool predicate::includes ( const pred_chain & chain) const
private
Return true if the domain defined by the predicate chain PREDS is
a subset of the domain of *THIS.  Return false if PREDS's domain
is not a subset of any of the sub-domains of *THIS (corresponding
to each individual chains in it), even though it may be still be
a subset of whole domain of *THIS which is the union (ORed) of all
its subdomains.  In other words, the result is conservative.   

References i, and subset_of().

◆ init_from_control_deps()

void predicate::init_from_control_deps ( const vec< edge > * dep_chains,
unsigned num_chains,
bool is_use )
Convert the chains of control dependence edges into a set of predicates.
A control dependence chain is represented by a vector edges.  DEP_CHAINS
points to an array of NUM_CHAINS dependence chains. One edge in
a dependence chain is mapped to predicate expression represented by
pred_info type.  One dependence chain is converted to a composite
predicate that is the result of AND operation of pred_info mapped to
each edge.  A composite predicate is represented by a vector of
pred_info.  Sets M_PREDS to the resulting composite predicates.   

References CASE_CHAIN, CASE_HIGH, CASE_LOW, cfun, pred_info::cond_code, DEBUG_PREDICATE_ANALYZER, dump_file, dump_pred_info(), dyn_cast(), EDGE_COUNT, empty_block_p(), FOR_EACH_EDGE, format_edge_vecs(), fputc(), gcc_assert, get_cases_for_edge(), gimple_cond_code(), gimple_cond_lhs(), gimple_cond_rhs(), gimple_switch_index(), gsi_last_bb(), i, pred_info::invert, is_empty(), operand_equal_p(), pred_info::pred_lhs, pred_info::pred_rhs, single_succ_p(), and stmt_can_throw_internal().

Referenced by uninit_analysis::init_from_phi_def(), and uninit_analysis::init_use_preds().

◆ is_empty()

◆ is_false()

bool predicate::is_false ( ) const
inline

References is_empty(), and m_cval.

Referenced by uninit_analysis::is_use_guarded().

◆ is_true()

bool predicate::is_true ( ) const
inline

References is_empty(), and m_cval.

Referenced by uninit_analysis::is_use_guarded().

◆ normalize() [1/4]

void predicate::normalize ( const pred_chain & chain)
private
Normalize a single predicate PRED_CHAIN and append it to *THIS.   

References hash_set< KeyId, Lazy, Traits >::add(), gcc_assert, i, chain::length, normalize(), and vNULL.

◆ normalize() [2/4]

void predicate::normalize ( const pred_info & pred)
private
Normalize PRED and store the normalized predicates in THIS->M_PREDS.   

References get_pred_info_from_cmp(), gimple_assign_rhs_code(), is_neq_zero_form_p(), normalize(), pred_info::pred_lhs, SSA_NAME_DEF_STMT, tcc_comparison, TREE_CODE_CLASS, and vNULL.

◆ normalize() [3/4]

void predicate::normalize ( gimple * use_or_def = NULL,
bool is_use = false )
Normalize predicate chains in THIS.   

References dump_file, dump_flags, i, normalize(), and TDF_DETAILS.

Referenced by uninit_analysis::is_use_guarded(), and normalize().

◆ normalize() [4/4]

void predicate::normalize ( pred_chain * norm_chain,
pred_info pred,
tree_code and_or_code,
pred_chain * work_list,
hash_set< tree > * mark_set )
private
Attempt to normalize predicate chains by following UD chains by
 building up a big tree of either IOR operations or AND operations,
 and converting the IOR tree into a pred_chain_union or the BIT_AND
 tree into a pred_chain.
 Example:

_3 = _2 RELOP1 _1;
_6 = _5 RELOP2 _4;
_9 = _8 RELOP3 _7;
_10 = _3 | _6;
_12 = _9 | _0;
_t = _10 | _12;

then _t != 0 will be normalized into a pred_chain_union

 (_2 RELOP1 _1) OR (_5 RELOP2 _4) OR (_8 RELOP3 _7) OR (_0 != 0)

 Similarly given:

_3 = _2 RELOP1 _1;
_6 = _5 RELOP2 _4;
_9 = _8 RELOP3 _7;
_10 = _3 & _6;
_12 = _9 & _0;

then _t != 0 will be normalized into a pred_chain:
(_2 RELOP1 _1) AND (_5 RELOP2 _4) AND (_8 RELOP3 _7) AND (_0 != 0)
Normalize predicate PRED:
1) if PRED can no longer be normalized, append it to *THIS.
2) otherwise if PRED is of the form x != 0, follow x's definition
   and put normalized predicates into WORK_LIST.   

References pred_info::cond_code, get_pred_info_from_cmp(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), gimple_phi_arg_def(), gimple_phi_num_args(), i, integer_zerop(), pred_info::invert, is_degenerate_phi(), is_gimple_min_invariant(), is_neq_zero_form_p(), pred_info::pred_lhs, pred_info::pred_rhs, push_to_worklist(), SSA_NAME_DEF_STMT, tcc_comparison, TREE_CODE, and TREE_CODE_CLASS.

◆ operator=()

predicate & predicate::operator= ( const predicate & rhs)
Copy-assign RHS to *THIS.   

References i.

◆ push_pred()

void predicate::push_pred ( const pred_info & pred)
private
Store a PRED in *THIS.   

References vNULL.

◆ simplify()

void predicate::simplify ( gimple * use_or_def = NULL,
bool is_use = false )
Simplify predicates in *THIS.   

References changed, dump_file, dump_flags, i, simplify_1a(), simplify_1b(), and TDF_DETAILS.

Referenced by uninit_analysis::is_use_guarded().

◆ simplify_2()

bool predicate::simplify_2 ( )
private
Implements rule 2 for the OR predicate PREDS:

2) (X AND Y) OR (!X AND Y) is equivalent to Y.   

References i, pred_equal_p(), and pred_neg_p().

◆ simplify_3()

bool predicate::simplify_3 ( )
private
Implement rule 3 for the OR predicate PREDS:

3) x OR (!x AND y) is equivalent to x OR y.   

References i, and pred_neg_p().

◆ simplify_4()

bool predicate::simplify_4 ( )
private
Implement rule 4 for the OR predicate PREDS:

2) ((x AND y) != 0) OR (x != 0 AND y != 0) is equivalent to
    (x != 0 AND y != 0).    

References gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), i, is_empty(), is_neq_zero_form_p(), pred_expr_equal_p(), pred_info::pred_lhs, SSA_NAME_DEF_STMT, and vNULL.

◆ superset_of()

bool predicate::superset_of ( const predicate & preds) const
Return true if the domain defined by *THIS is a superset of PREDS's
domain.
Avoid building generic trees (and rely on the folding capability
of the compiler), and instead perform brute force comparison of
individual predicate chains (this won't be a computationally costly
since the chains are pretty short).  Returning false does not
necessarily mean *THIS is not a superset of *PREDS, only that
it need not be since the analysis cannot prove it.   

References i, includes, and m_preds.

Referenced by uninit_analysis::is_use_guarded().

Field Documentation

◆ location

◆ m_cval

bool predicate::m_cval
private

Referenced by empty_val(), is_false(), and is_true().

◆ m_preds

pred_chain_union predicate::m_preds
private

Referenced by chain(), is_empty(), and superset_of().

◆ p

predicate_id* predicate::p

◆ type


The documentation for this class was generated from the following files: