GCC Middle and Back End API Reference
vr-values.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "insn-codes.h"
#include "tree.h"
#include "gimple.h"
#include "ssa.h"
#include "optabs-tree.h"
#include "gimple-pretty-print.h"
#include "diagnostic-core.h"
#include "flags.h"
#include "fold-const.h"
#include "calls.h"
#include "cfganal.h"
#include "gimple-iterator.h"
#include "gimple-fold.h"
#include "tree-cfg.h"
#include "tree-ssa-loop-niter.h"
#include "tree-ssa-loop.h"
#include "intl.h"
#include "cfgloop.h"
#include "tree-scalar-evolution.h"
#include "tree-ssa-propagate.h"
#include "tree-chrec.h"
#include "omp-general.h"
#include "case-cfn-macros.h"
#include "alloc-pool.h"
#include "attribs.h"
#include "range.h"
#include "vr-values.h"
#include "cfghooks.h"
#include "range-op.h"
#include "gimple-range.h"
Include dependency graph for vr-values.cc:

Functions

static bool check_for_binary_op_overflow (range_query *query, enum tree_code subcode, tree type, tree op0, tree op1, bool *ovf, gimple *s=NULL)
 
static bool get_scev_info (vrange &r, tree name, gimple *stmt, class loop *l, tree &init, tree &step, enum ev_direction &dir)
 
static bool induction_variable_may_overflow_p (tree type, const wide_int &step, const widest_int &nit)
 
static void range_from_loop_direction (irange &r, tree type, const irange &begin, const irange &end, ev_direction dir)
 
bool range_of_var_in_loop (vrange &v, tree name, class loop *l, gimple *stmt, range_query *query)
 
static bool find_case_label_ranges (gswitch *stmt, const irange *vr, size_t *min_idx1, size_t *max_idx1, size_t *min_idx2, size_t *max_idx2)
 
static bool vr_set_zero_nonzero_bits (const tree expr_type, const irange *vr, wide_int *may_be_nonzero, wide_int *must_be_nonzero)
 
static tree test_for_singularity (enum tree_code cond_code, tree op0, tree op1, const irange *vr)
 
bool range_fits_type_p (const irange *vr, unsigned dest_precision, signop dest_sgn)
 
static bool simplify_conversion_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
 

Function Documentation

◆ check_for_binary_op_overflow()

static bool check_for_binary_op_overflow ( range_query * query,
enum tree_code subcode,
tree type,
tree op0,
tree op1,
bool * ovf,
gimple * s = NULL )
static
Helper function for simplify_internal_call_using_ranges and
extract_range_basic.  Return true if OP0 SUBCODE OP1 for
SUBCODE {PLUS,MINUS,MULT}_EXPR is known to never overflow or
always overflow.  Set *OVF to true if it is known to always
overflow.   

References wi::add(), arith_overflowed_p(), gcc_unreachable, i, irange_val_max(), irange_val_min(), irange::lower_bound(), wi::mul(), range_query::range_of_expr(), irange::set_varying(), wi::smax(), wi::smin(), wi::sub(), TREE_TYPE, TYPE_SIGN, vrange::undefined_p(), irange::upper_bound(), and wide_int_to_tree().

Referenced by simplify_using_ranges::simplify_internal_call_using_ranges().

◆ find_case_label_ranges()

static bool find_case_label_ranges ( gswitch * stmt,
const irange * vr,
size_t * min_idx1,
size_t * max_idx1,
size_t * min_idx2,
size_t * max_idx2 )
static
Searches the case label vector VEC for the ranges of CASE_LABELs that are
used in range VR.  The indices are placed in MIN_IDX1, MAX_IDX, MIN_IDX2 and
MAX_IDX2.  If the ranges of CASE_LABELs are empty then MAX_IDX1 < MIN_IDX1.
Returns true if the default label is not needed.   

References CASE_HIGH, CASE_LOW, find_case_label_range(), gcc_checking_assert, get_legacy_range(), gimple_switch_label(), gimple_switch_num_labels(), i, NULL_TREE, tree_int_cst_compare(), vrange::undefined_p(), vrange::varying_p(), and VR_RANGE.

Referenced by simplify_using_ranges::simplify_switch_using_ranges().

◆ get_scev_info()

static bool get_scev_info ( vrange & r,
tree name,
gimple * stmt,
class loop * l,
tree & init,
tree & step,
enum ev_direction & dir )
static
Set INIT, STEP, and DIRECTION to the corresponding values of NAME
within LOOP, and return TRUE.  Otherwise return FALSE, and set R to
the conservative range of NAME within the loop.   

References analyze_scalar_evolution(), EV_DIR_UNKNOWN, evolution_part_in_loop_num(), get_chrec_loop(), initial_condition_in_loop_num(), instantiate_parameters(), is_gimple_constant(), is_gimple_min_invariant(), NULL, loop::num, r, scev_direction(), scev_probably_wraps_p(), TREE_CODE, and TREE_TYPE.

Referenced by range_of_var_in_loop().

◆ induction_variable_may_overflow_p()

static bool induction_variable_may_overflow_p ( tree type,
const wide_int & step,
const widest_int & nit )
static
Return TRUE if STEP * NIT may overflow when calculated in TYPE.   

References wi::fits_to_tree_p(), wi::gts_p(), wi::mul(), SIGNED, and TYPE_SIGN.

Referenced by range_of_var_in_loop().

◆ range_fits_type_p()

bool range_fits_type_p ( const irange * vr,
unsigned dest_precision,
signop dest_sgn )

◆ range_from_loop_direction()

static void range_from_loop_direction ( irange & r,
tree type,
const irange & begin,
const irange & end,
ev_direction dir )
static
Set R to the range from BEGIN to END, assuming the direction of the
loop is DIR.   

References begin(), end(), EV_DIR_GROWS, wi::gt_p(), r, and TYPE_SIGN.

Referenced by range_of_var_in_loop().

◆ range_of_var_in_loop()

bool range_of_var_in_loop ( vrange & v,
tree name,
class loop * l,
gimple * stmt,
range_query * query )

◆ simplify_conversion_using_ranges()

◆ test_for_singularity()

static tree test_for_singularity ( enum tree_code cond_code,
tree op0,
tree op1,
const irange * vr )
static
We are comparing trees OP0 and OP1 using COND_CODE.  OP0 has
a known value range VR.

If there is one and only one value which will satisfy the
conditional, then return that value.  Else return NULL.

If signed overflow must be undefined for the value to satisfy
the conditional, then set *STRICT_OVERFLOW_P to true.   

References build_int_cst(), compare_values(), EXPR_P, fold_build2, is_gimple_min_invariant(), irange::lower_bound(), NULL, operand_equal_p(), suppress_warning(), TREE_TYPE, TYPE_MAX_VALUE, TYPE_MIN_VALUE, irange::upper_bound(), and wide_int_to_tree().

Referenced by dom_opt_dom_walker::optimize_stmt(), and simplify_using_ranges::simplify_compare_using_ranges_1().

◆ vr_set_zero_nonzero_bits()

static bool vr_set_zero_nonzero_bits ( const tree expr_type,
const irange * vr,
wide_int * may_be_nonzero,
wide_int * must_be_nonzero )
static
irange wrapper for wi_set_zero_nonzero_bits.

Return TRUE if VR was a constant range and we were able to compute
the bit masks.   

References irange::lower_bound(), wi::minus_one(), TYPE_PRECISION, vrange::undefined_p(), irange::upper_bound(), vrange::varying_p(), wi_set_zero_nonzero_bits(), and wi::zero().

Referenced by simplify_using_ranges::simplify_bit_ops_using_ranges().