The base class for ranges is currently value_range_base, which is rather long and cumbersome.

The base class for ranges is currently value_range_base, which is
rather long and cumbersome.  It also occurs more often than the derived
class of value_range.  To avoid confusion, and save typing, this
patch does a global rename from value_range to value_range_equiv,
and from value_range_base to value_range.

This way, the base class is simply value_range, and the derived
class is value_range_equiv which explicitly states what it does.

From-SVN: r277847
This commit is contained in:
Aldy Hernandez 2019-11-05 15:39:11 +00:00 committed by Aldy Hernandez
parent 3619076a63
commit 028d81b159
24 changed files with 1155 additions and 1167 deletions

View file

@ -1,3 +1,13 @@
2019-11-05 Aldy Hernandez <aldyh@redhat.com>
* gimple-fold.c, gimple-loop-versioning.cc,
gimple-ssa-evrp-analyze.[ch], gimple-ssa-evrp.c,
gimple-ssa-sprintf.c, ipa-cp.c, ipa-prop.c, ipa-prop.h,
range-op.[hc]*, range.[hc]*, selftest.h, tree-ssa-dom.c,
tree-ssa-strlen.c, tree-ssa-threadedge.c, tree-ssanames.[hc],
tree-vrp.[hc], vr-values.[hc]: Global rename of value_range to
value_range_equiv, and value_range_base to value_range.
2019-11-05 Matthew Malcomson <matthew.malcomson@arm.com>
* expr.c (build_personality_function): Fix generated type to

View file

@ -677,10 +677,10 @@ size_must_be_zero_p (tree size)
/* Compute the value of SSIZE_MAX, the largest positive value that
can be stored in ssize_t, the signed counterpart of size_t. */
wide_int ssize_max = wi::lshift (wi::one (prec), prec - 1) - 1;
value_range_base valid_range (VR_RANGE,
build_int_cst (type, 0),
wide_int_to_tree (type, ssize_max));
value_range_base vr;
value_range valid_range (VR_RANGE,
build_int_cst (type, 0),
wide_int_to_tree (type, ssize_max));
value_range vr;
get_range_info (size, vr);
vr.intersect (&valid_range);
return vr.zero_p ();

View file

@ -1495,7 +1495,7 @@ loop_versioning::prune_loop_conditions (class loop *loop, vr_values *vrs)
EXECUTE_IF_SET_IN_BITMAP (&li.unity_names, 0, i, bi)
{
tree name = ssa_name (i);
const value_range *vr = vrs->get_value_range (name);
const value_range_equiv *vr = vrs->get_value_range (name);
if (vr && !vr->may_contain_p (build_one_cst (TREE_TYPE (name))))
{
if (dump_enabled_p ())

View file

@ -62,7 +62,7 @@ evrp_range_analyzer::evrp_range_analyzer (bool update_global_ranges)
void
evrp_range_analyzer::push_marker ()
{
stack.safe_push (std::make_pair (NULL_TREE, (value_range *)NULL));
stack.safe_push (std::make_pair (NULL_TREE, (value_range_equiv *)NULL));
}
/* Analyze ranges as we enter basic block BB. */
@ -79,12 +79,12 @@ evrp_range_analyzer::enter (basic_block bb)
}
/* Find new range for NAME such that (OP CODE LIMIT) is true. */
value_range *
value_range_equiv *
evrp_range_analyzer::try_find_new_range (tree name,
tree op, tree_code code, tree limit)
tree op, tree_code code, tree limit)
{
value_range vr;
const value_range *old_vr = get_value_range (name);
value_range_equiv vr;
const value_range_equiv *old_vr = get_value_range (name);
/* Discover VR when condition is true. */
vr_values->extract_range_for_var_from_comparison_expr (name, code, op,
@ -93,11 +93,9 @@ evrp_range_analyzer::try_find_new_range (tree name,
PUSH old value in the stack with the old VR. */
if (!vr.undefined_p () && !vr.varying_p ())
{
if (old_vr->kind () == vr.kind ()
&& vrp_operand_equal_p (old_vr->min (), vr.min ())
&& vrp_operand_equal_p (old_vr->max (), vr.max ()))
if (old_vr->equal_p (vr, /*ignore_equivs=*/true))
return NULL;
value_range *new_vr = vr_values->allocate_value_range ();
value_range_equiv *new_vr = vr_values->allocate_value_range_equiv ();
new_vr->move (&vr);
return new_vr;
}
@ -106,7 +104,7 @@ evrp_range_analyzer::try_find_new_range (tree name,
/* For LHS record VR in the SSA info. */
void
evrp_range_analyzer::set_ssa_range_info (tree lhs, value_range *vr)
evrp_range_analyzer::set_ssa_range_info (tree lhs, value_range_equiv *vr)
{
gcc_assert (m_update_global_ranges);
@ -187,13 +185,14 @@ evrp_range_analyzer::record_ranges_from_incoming_edge (basic_block bb)
if (TREE_CODE (op1) == SSA_NAME)
register_edge_assert_for (op1, pred_e, code, op0, op1, asserts);
auto_vec<std::pair<tree, value_range *>, 8> vrs;
auto_vec<std::pair<tree, value_range_equiv *>, 8> vrs;
for (unsigned i = 0; i < asserts.length (); ++i)
{
value_range *vr = try_find_new_range (asserts[i].name,
asserts[i].expr,
asserts[i].comp_code,
asserts[i].val);
value_range_equiv *vr
= try_find_new_range (asserts[i].name,
asserts[i].expr,
asserts[i].comp_code,
asserts[i].val);
if (vr)
vrs.safe_push (std::make_pair (asserts[i].name, vr));
}
@ -209,9 +208,9 @@ evrp_range_analyzer::record_ranges_from_incoming_edge (basic_block bb)
/* But make sure we do not weaken ranges like when
getting first [64, +INF] and then ~[0, 0] from
conditions like (s & 0x3cc0) == 0). */
const value_range *old_vr = get_value_range (vrs[i].first);
value_range_base tem (old_vr->kind (), old_vr->min (),
old_vr->max ());
const value_range_equiv *old_vr
= get_value_range (vrs[i].first);
value_range tem (*old_vr);
tem.intersect (vrs[i].second);
if (tem.equal_p (*old_vr))
{
@ -256,10 +255,10 @@ evrp_range_analyzer::record_ranges_from_phis (basic_block bb)
/* Skips floats and other things we can't represent in a
range. */
if (!value_range_base::supports_type_p (TREE_TYPE (lhs)))
if (!value_range::supports_type_p (TREE_TYPE (lhs)))
continue;
value_range vr_result;
value_range_equiv vr_result;
bool interesting = stmt_interesting_for_vrp (phi);
if (!has_unvisited_preds && interesting)
vr_values->extract_range_from_phi_node (phi, &vr_result);
@ -303,7 +302,7 @@ evrp_range_analyzer::record_ranges_from_stmt (gimple *stmt, bool temporary)
else if (stmt_interesting_for_vrp (stmt))
{
edge taken_edge;
value_range vr;
value_range_equiv vr;
vr_values->extract_range_from_stmt (stmt, &taken_edge, &output, &vr);
if (output)
{
@ -333,7 +332,8 @@ evrp_range_analyzer::record_ranges_from_stmt (gimple *stmt, bool temporary)
a new range and push the old range onto the stack. We
also have to be very careful about sharing the underlying
bitmaps. Ugh. */
value_range *new_vr = vr_values->allocate_value_range ();
value_range_equiv *new_vr
= vr_values->allocate_value_range_equiv ();
new_vr->set (vr.kind (), vr.min (), vr.max ());
vr.equiv_clear ();
push_value_range (output, new_vr);
@ -379,15 +379,15 @@ evrp_range_analyzer::record_ranges_from_stmt (gimple *stmt, bool temporary)
/* Add VR when (T COMP_CODE value) condition is
true. */
value_range *op_range
value_range_equiv *op_range
= try_find_new_range (t, t, comp_code, value);
if (op_range)
push_value_range (t, op_range);
}
}
/* Add VR when (OP COMP_CODE value) condition is true. */
value_range *op_range = try_find_new_range (op, op,
comp_code, value);
value_range_equiv *op_range = try_find_new_range (op, op,
comp_code, value);
if (op_range)
push_value_range (op, op_range);
}
@ -419,7 +419,7 @@ evrp_range_analyzer::leave (basic_block bb ATTRIBUTE_UNUSED)
/* Push the Value Range of VAR to the stack and update it with new VR. */
void
evrp_range_analyzer::push_value_range (tree var, value_range *vr)
evrp_range_analyzer::push_value_range (tree var, value_range_equiv *vr)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@ -429,7 +429,7 @@ evrp_range_analyzer::push_value_range (tree var, value_range *vr)
dump_value_range (dump_file, vr);
fprintf (dump_file, "\n");
}
value_range *old_vr = vr_values->swap_vr_value (var, vr);
value_range_equiv *old_vr = vr_values->swap_vr_value (var, vr);
stack.safe_push (std::make_pair (var, old_vr));
}
@ -438,9 +438,9 @@ evrp_range_analyzer::push_value_range (tree var, value_range *vr)
void
evrp_range_analyzer::pop_value_range ()
{
std::pair<tree, value_range *> e = stack.pop ();
std::pair<tree, value_range_equiv *> e = stack.pop ();
tree var = e.first;
value_range *vr = e.second;
value_range_equiv *vr = e.second;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "popping range for ");
@ -451,7 +451,7 @@ evrp_range_analyzer::pop_value_range ()
}
/* We saved off a lattice entry, now give it back and release
the one we popped. */
value_range *popped_vr = vr_values->swap_vr_value (var, vr);
value_range_equiv *popped_vr = vr_values->swap_vr_value (var, vr);
if (popped_vr)
vr_values->free_value_range (popped_vr);
}

View file

@ -37,11 +37,11 @@ class evrp_range_analyzer
void record_ranges_from_stmt (gimple *, bool);
/* Main interface to retrieve range information. */
const value_range *get_value_range (const_tree op)
const value_range_equiv *get_value_range (const_tree op)
{ return vr_values->get_value_range (op); }
/* Record a new unwindable range. */
void push_value_range (tree var, value_range *vr);
void push_value_range (tree var, value_range_equiv *vr);
/* Dump all the current value ranges. This is primarily
a debugging interface. */
@ -63,13 +63,14 @@ class evrp_range_analyzer
class vr_values *vr_values;
void pop_value_range ();
value_range *try_find_new_range (tree, tree op, tree_code code, tree limit);
value_range_equiv *try_find_new_range (tree, tree op, tree_code code,
tree limit);
void record_ranges_from_incoming_edge (basic_block);
void record_ranges_from_phis (basic_block);
void set_ssa_range_info (tree, value_range *);
void set_ssa_range_info (tree, value_range_equiv *);
/* STACK holds the old VR. */
auto_vec<std::pair <tree, value_range *> > stack;
auto_vec<std::pair <tree, value_range_equiv *> > stack;
/* True if we are updating global ranges, false otherwise. */
bool m_update_global_ranges;

View file

@ -109,7 +109,7 @@ evrp_dom_walker::before_dom_children (basic_block bb)
if (virtual_operand_p (lhs))
continue;
const value_range *vr = evrp_range_analyzer.get_value_range (lhs);
const value_range_equiv *vr = evrp_range_analyzer.get_value_range (lhs);
/* Mark PHIs whose lhs we fully propagate for removal. */
tree val;
if (vr->singleton_p (&val) && may_propagate_copy (lhs, val))
@ -158,11 +158,11 @@ evrp_dom_walker::before_dom_children (basic_block bb)
output = get_output_for_vrp (stmt);
if (output)
{
tree val;
const value_range *vr
const value_range_equiv *vr
= evrp_range_analyzer.get_value_range (output);
/* Mark stmts whose output we fully propagate for removal. */
tree val;
if (vr->singleton_p (&val)
&& may_propagate_copy (output, val)
&& !stmt_could_throw_p (cfun, stmt)
@ -244,7 +244,8 @@ evrp_dom_walker::before_dom_children (basic_block bb)
if (TREE_CODE (arg) != SSA_NAME
|| virtual_operand_p (arg))
continue;
const value_range *vr = evrp_range_analyzer.get_value_range (arg);
const value_range_equiv
*vr = evrp_range_analyzer.get_value_range (arg);
tree val;
if (vr->singleton_p (&val) && may_propagate_copy (arg, val))
propagate_value (use_p, val);

View file

@ -1021,7 +1021,7 @@ get_int_range (tree arg, HOST_WIDE_INT *pmin, HOST_WIDE_INT *pmax,
&& TYPE_PRECISION (argtype) <= TYPE_PRECISION (type))
{
/* Try to determine the range of values of the integer argument. */
const value_range *vr
const value_range_equiv *vr
= CONST_CAST (class vr_values *, vr_values)->get_value_range (arg);
if (range_int_cst_p (vr))
@ -1323,7 +1323,7 @@ format_integer (const directive &dir, tree arg, const vr_values *vr_values)
{
/* Try to determine the range of values of the integer argument
(range information is not available for pointers). */
const value_range *vr
const value_range_equiv *vr
= CONST_CAST (class vr_values *, vr_values)->get_value_range (arg);
if (range_int_cst_p (vr))
@ -4087,7 +4087,7 @@ handle_printf_call (gimple_stmt_iterator *gsi, const vr_values *vr_values)
/* Try to determine the range of values of the argument
and use the greater of the two at level 1 and the smaller
of them at level 2. */
const value_range *vr
const value_range_equiv *vr
= CONST_CAST (class vr_values *, vr_values)->get_value_range (size);
if (range_int_cst_p (vr))

View file

@ -307,18 +307,18 @@ private:
class ipcp_vr_lattice
{
public:
value_range_base m_vr;
value_range m_vr;
inline bool bottom_p () const;
inline bool top_p () const;
inline bool set_to_bottom ();
bool meet_with (const value_range_base *p_vr);
bool meet_with (const value_range *p_vr);
bool meet_with (const ipcp_vr_lattice &other);
void init () { gcc_assert (m_vr.undefined_p ()); }
void print (FILE * f);
private:
bool meet_with_1 (const value_range_base *other_vr);
bool meet_with_1 (const value_range *other_vr);
};
/* Structure containing lattices for a parameter itself and for pieces of
@ -930,7 +930,7 @@ ipcp_vr_lattice::meet_with (const ipcp_vr_lattice &other)
lattice. */
bool
ipcp_vr_lattice::meet_with (const value_range_base *p_vr)
ipcp_vr_lattice::meet_with (const value_range *p_vr)
{
return meet_with_1 (p_vr);
}
@ -939,7 +939,7 @@ ipcp_vr_lattice::meet_with (const value_range_base *p_vr)
OTHER_VR lattice. Return TRUE if anything changed. */
bool
ipcp_vr_lattice::meet_with_1 (const value_range_base *other_vr)
ipcp_vr_lattice::meet_with_1 (const value_range *other_vr)
{
if (bottom_p ())
return false;
@ -947,7 +947,7 @@ ipcp_vr_lattice::meet_with_1 (const value_range_base *other_vr)
if (other_vr->varying_p ())
return set_to_bottom ();
value_range_base save (m_vr);
value_range save (m_vr);
m_vr.union_ (other_vr);
return !m_vr.equal_p (save);
}
@ -1939,8 +1939,8 @@ propagate_bits_across_jump_function (cgraph_edge *cs, int idx,
the result is a range or an anti-range. */
static bool
ipa_vr_operation_and_type_effects (value_range_base *dst_vr,
value_range_base *src_vr,
ipa_vr_operation_and_type_effects (value_range *dst_vr,
value_range *src_vr,
enum tree_code operation,
tree dst_type, tree src_type)
{
@ -1983,7 +1983,7 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc,
if (src_lats->m_value_range.bottom_p ())
return dest_lat->set_to_bottom ();
value_range_base vr;
value_range vr;
if (ipa_vr_operation_and_type_effects (&vr,
&src_lats->m_value_range.m_vr,
operation, param_type,
@ -2000,12 +2000,12 @@ propagate_vr_across_jump_function (cgraph_edge *cs, ipa_jump_func *jfunc,
if (TREE_OVERFLOW_P (val))
val = drop_tree_overflow (val);
value_range_base tmpvr (VR_RANGE, val, val);
value_range tmpvr (VR_RANGE, val, val);
return dest_lat->meet_with (&tmpvr);
}
}
value_range_base vr;
value_range vr;
if (jfunc->m_vr
&& ipa_vr_operation_and_type_effects (&vr, jfunc->m_vr, NOP_EXPR,
param_type,

View file

@ -107,12 +107,12 @@ static GTY ((cache)) hash_table<ipa_bit_ggc_hash_traits> *ipa_bits_hash_table;
/* Traits for a hash table for reusing value_ranges used for IPA. Note that
the equiv bitmap is not hashed and is expected to be NULL. */
struct ipa_vr_ggc_hash_traits : public ggc_cache_remove <value_range_base *>
struct ipa_vr_ggc_hash_traits : public ggc_cache_remove <value_range *>
{
typedef value_range_base *value_type;
typedef value_range_base *compare_type;
typedef value_range *value_type;
typedef value_range *compare_type;
static hashval_t
hash (const value_range_base *p)
hash (const value_range *p)
{
inchash::hash hstate (p->kind ());
inchash::add_expr (p->min (), hstate);
@ -120,29 +120,29 @@ struct ipa_vr_ggc_hash_traits : public ggc_cache_remove <value_range_base *>
return hstate.end ();
}
static bool
equal (const value_range_base *a, const value_range_base *b)
equal (const value_range *a, const value_range *b)
{
return a->equal_p (*b);
}
static void
mark_empty (value_range_base *&p)
mark_empty (value_range *&p)
{
p = NULL;
}
static bool
is_empty (const value_range_base *p)
is_empty (const value_range *p)
{
return p == NULL;
}
static bool
is_deleted (const value_range_base *p)
is_deleted (const value_range *p)
{
return p == reinterpret_cast<const value_range_base *> (1);
return p == reinterpret_cast<const value_range *> (1);
}
static void
mark_deleted (value_range_base *&p)
mark_deleted (value_range *&p)
{
p = reinterpret_cast<value_range_base *> (1);
p = reinterpret_cast<value_range *> (1);
}
};
@ -1802,14 +1802,14 @@ ipa_set_jfunc_bits (ipa_jump_func *jf, const widest_int &value,
/* Return a pointer to a value_range just like *TMP, but either find it in
ipa_vr_hash_table or allocate it in GC memory. TMP->equiv must be NULL. */
static value_range_base *
ipa_get_value_range (value_range_base *tmp)
static value_range *
ipa_get_value_range (value_range *tmp)
{
value_range_base **slot = ipa_vr_hash_table->find_slot (tmp, INSERT);
value_range **slot = ipa_vr_hash_table->find_slot (tmp, INSERT);
if (*slot)
return *slot;
value_range_base *vr = ggc_alloc<value_range_base> ();
value_range *vr = ggc_alloc<value_range> ();
*vr = *tmp;
*slot = vr;
@ -1820,10 +1820,10 @@ ipa_get_value_range (value_range_base *tmp)
equiv set. Use hash table in order to avoid creating multiple same copies of
value_ranges. */
static value_range_base *
static value_range *
ipa_get_value_range (enum value_range_kind type, tree min, tree max)
{
value_range_base tmp (type, min, max);
value_range tmp (type, min, max);
return ipa_get_value_range (&tmp);
}
@ -1842,7 +1842,7 @@ ipa_set_jfunc_vr (ipa_jump_func *jf, enum value_range_kind type,
copy from ipa_vr_hash_table or allocate a new on in GC memory. */
static void
ipa_set_jfunc_vr (ipa_jump_func *jf, value_range_base *tmp)
ipa_set_jfunc_vr (ipa_jump_func *jf, value_range *tmp)
{
jf->m_vr = ipa_get_value_range (tmp);
}
@ -1919,8 +1919,8 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
&& (type = get_range_info (arg, &min, &max))
&& (type == VR_RANGE || type == VR_ANTI_RANGE))
{
value_range_base resvr;
value_range_base tmpvr (type,
value_range resvr;
value_range tmpvr (type,
wide_int_to_tree (TREE_TYPE (arg), min),
wide_int_to_tree (TREE_TYPE (arg), max));
range_fold_unary_expr (&resvr, NOP_EXPR, param_type,

View file

@ -205,7 +205,7 @@ struct GTY (()) ipa_jump_func
/* Information about value range, containing valid data only when vr_known is
true. The pointed to structure is shared betweed different jump
functions. Use ipa_set_jfunc_vr to set this field. */
class value_range_base *m_vr;
class value_range *m_vr;
enum jump_func_type type;
/* Represents a value of a jump function. pass_through is used only in jump

File diff suppressed because it is too large Load diff

View file

@ -50,9 +50,9 @@ class range_operator
{
public:
// Perform an operation between 2 ranges and return it.
virtual value_range_base fold_range (tree type,
const value_range_base &lh,
const value_range_base &rh) const;
virtual value_range fold_range (tree type,
const value_range &lh,
const value_range &rh) const;
// Return the range for op[12] in the general case. LHS is the range for
// the LHS of the expression, OP[12]is the range for the other
@ -65,16 +65,16 @@ public:
//
// i.e. [LHS] = ??? + OP2
// is re-formed as R = [LHS] - OP2.
virtual bool op1_range (value_range_base &r, tree type,
const value_range_base &lhs,
const value_range_base &op2) const;
virtual bool op2_range (value_range_base &r, tree type,
const value_range_base &lhs,
const value_range_base &op1) const;
virtual bool op1_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op2) const;
virtual bool op2_range (value_range &r, tree type,
const value_range &lhs,
const value_range &op1) const;
protected:
// Perform an operation between 2 sub-ranges and return it.
virtual value_range_base wi_fold (tree type,
virtual value_range wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
@ -82,7 +82,7 @@ protected:
};
extern range_operator *range_op_handler (enum tree_code code, tree type);
extern void range_cast (value_range_base &, tree type);
extern void range_cast (value_range &, tree type);
extern void wi_set_zero_nonzero_bits (tree type,
const wide_int &, const wide_int &,
wide_int &maybe_nonzero,

View file

@ -29,61 +29,60 @@ along with GCC; see the file COPYING3. If not see
#include "ssa.h"
#include "range.h"
value_range_base
range_intersect (const value_range_base &r1, const value_range_base &r2)
value_range
range_intersect (const value_range &r1, const value_range &r2)
{
value_range_base tmp (r1);
value_range tmp (r1);
tmp.intersect (r2);
return tmp;
}
value_range_base
range_invert (const value_range_base &r1)
value_range
range_invert (const value_range &r1)
{
value_range_base tmp (r1);
value_range tmp (r1);
tmp.invert ();
return tmp;
}
value_range_base
range_union (const value_range_base &r1, const value_range_base &r2)
value_range
range_union (const value_range &r1, const value_range &r2)
{
value_range_base tmp (r1);
value_range tmp (r1);
tmp.union_ (r2);
return tmp;
}
value_range_base
value_range
range_zero (tree type)
{
return value_range_base (build_zero_cst (type), build_zero_cst (type));
return value_range (build_zero_cst (type), build_zero_cst (type));
}
value_range_base
value_range
range_nonzero (tree type)
{
return value_range_base (VR_ANTI_RANGE,
return value_range (VR_ANTI_RANGE,
build_zero_cst (type), build_zero_cst (type));
}
value_range_base
value_range
range_positives (tree type)
{
unsigned prec = TYPE_PRECISION (type);
signop sign = TYPE_SIGN (type);
return value_range_base (type, wi::zero (prec), wi::max_value (prec, sign));
return value_range (type, wi::zero (prec), wi::max_value (prec, sign));
}
value_range_base
value_range
range_negatives (tree type)
{
unsigned prec = TYPE_PRECISION (type);
signop sign = TYPE_SIGN (type);
value_range_base r;
value_range r;
if (sign == UNSIGNED)
r.set_undefined ();
else
r = value_range_base (type, wi::min_value (prec, sign),
wi::minus_one (prec));
r = value_range (type, wi::min_value (prec, sign), wi::minus_one (prec));
return r;
}

View file

@ -21,13 +21,11 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_RANGE_H
#define GCC_RANGE_H
value_range_base range_zero (tree type);
value_range_base range_nonzero (tree type);
value_range_base range_intersect (const value_range_base &,
const value_range_base &);
value_range_base range_union (const value_range_base &,
const value_range_base &);
value_range_base range_invert (const value_range_base &);
value_range_base range_positives (tree type);
value_range_base range_negatives (tree type);
value_range range_zero (tree type);
value_range range_nonzero (tree type);
value_range range_intersect (const value_range &, const value_range &);
value_range range_union (const value_range &, const value_range &);
value_range range_invert (const value_range &);
value_range range_positives (tree type);
value_range range_negatives (tree type);
#endif // GCC_RANGE_H

View file

@ -260,7 +260,7 @@ extern int num_passes;
} /* end of namespace selftest. */
/* This is outside of the selftest namespace because it's a friend of
value_range_base. */
value_range. */
extern void range_tests ();
/* Macros for writing tests. */

View file

@ -901,7 +901,7 @@ simplify_stmt_for_jump_threading (gimple *stmt,
if (TREE_CODE (op) != SSA_NAME)
return NULL_TREE;
const value_range *vr = x_vr_values->get_value_range (op);
const value_range_equiv *vr = x_vr_values->get_value_range (op);
if (vr->undefined_p ()
|| vr->varying_p ()
|| vr->symbolic_p ())
@ -963,9 +963,9 @@ simplify_stmt_for_jump_threading (gimple *stmt,
{
edge dummy_e;
tree dummy_tree;
value_range new_vr;
value_range_equiv new_vr;
x_vr_values->extract_range_from_stmt (stmt, &dummy_e,
&dummy_tree, &new_vr);
&dummy_tree, &new_vr);
tree singleton;
if (new_vr.singleton_p (&singleton))
return singleton;

View file

@ -225,7 +225,7 @@ compare_nonzero_chars (strinfo *si, unsigned HOST_WIDE_INT off,
if (!rvals || TREE_CODE (si->nonzero_chars) != SSA_NAME)
return -1;
const value_range *vr
const value_range_equiv *vr
= (CONST_CAST (class vr_values *, rvals)
->get_value_range (si->nonzero_chars));
@ -799,7 +799,7 @@ dump_strlen_info (FILE *fp, gimple *stmt, const vr_values *rvals)
wide_int min, max;
if (rvals)
{
const value_range *vr
const value_range_equiv *vr
= CONST_CAST (class vr_values *, rvals)
->get_value_range (si->nonzero_chars);
rng = vr->kind ();
@ -991,7 +991,7 @@ get_range_strlen_dynamic (tree src, c_strlen_data *pdata, bitmap *visited,
pdata->minlen = si->nonzero_chars;
else if (TREE_CODE (si->nonzero_chars) == SSA_NAME)
{
const value_range *vr
const value_range_equiv *vr
= CONST_CAST (class vr_values *, rvals)
->get_value_range (si->nonzero_chars);
if (vr->kind () == VR_RANGE
@ -1031,7 +1031,7 @@ get_range_strlen_dynamic (tree src, c_strlen_data *pdata, bitmap *visited,
}
else if (pdata->minlen && TREE_CODE (pdata->minlen) == SSA_NAME)
{
const value_range *vr
const value_range_equiv *vr
= CONST_CAST (class vr_values *, rvals)
->get_value_range (si->nonzero_chars);
if (vr->kind () == VR_RANGE
@ -4040,7 +4040,7 @@ count_nonzero_bytes (tree exp, unsigned HOST_WIDE_INT offset,
&& si->nonzero_chars
&& TREE_CODE (si->nonzero_chars) == SSA_NAME)
{
const value_range *vr
const value_range_equiv *vr
= CONST_CAST (class vr_values *, rvals)
->get_value_range (si->nonzero_chars);
if (vr->kind () != VR_RANGE

View file

@ -165,8 +165,8 @@ record_temporary_equivalences_from_phis (edge e,
/* Get an empty new VR we can pass to update_value_range and save
away in the VR stack. */
vr_values *vr_values = evrp_range_analyzer->get_vr_values ();
value_range *new_vr = vr_values->allocate_value_range ();
new (new_vr) value_range ();
value_range_equiv *new_vr = vr_values->allocate_value_range_equiv ();
new (new_vr) value_range_equiv ();
/* There are three cases to consider:

View file

@ -408,7 +408,7 @@ set_range_info (tree name, enum value_range_kind range_type,
/* Store range information for NAME from a value_range. */
void
set_range_info (tree name, const value_range_base &vr)
set_range_info (tree name, const value_range &vr)
{
wide_int min = wi::to_wide (vr.min ());
wide_int max = wi::to_wide (vr.max ());
@ -441,7 +441,7 @@ get_range_info (const_tree name, wide_int *min, wide_int *max)
in a value_range VR. Returns the value_range_kind. */
enum value_range_kind
get_range_info (const_tree name, value_range_base &vr)
get_range_info (const_tree name, value_range &vr)
{
tree min, max;
wide_int wmin, wmax;

View file

@ -69,11 +69,11 @@ struct GTY ((variable_size)) range_info_def {
/* Sets the value range to SSA. */
extern void set_range_info (tree, enum value_range_kind, const wide_int_ref &,
const wide_int_ref &);
extern void set_range_info (tree, const value_range_base &);
extern void set_range_info (tree, const value_range &);
/* Gets the value range from SSA. */
extern enum value_range_kind get_range_info (const_tree, wide_int *,
wide_int *);
extern enum value_range_kind get_range_info (const_tree, value_range_base &);
extern enum value_range_kind get_range_info (const_tree, value_range &);
extern void set_nonzero_bits (tree, const wide_int_ref &);
extern wide_int get_nonzero_bits (const_tree);
extern bool ssa_name_has_boolean_range (tree);

View file

@ -70,15 +70,15 @@ along with GCC; see the file COPYING3. If not see
#include "range-op.h"
static bool
ranges_from_anti_range (const value_range_base *ar,
value_range_base *vr0, value_range_base *vr1);
ranges_from_anti_range (const value_range *ar,
value_range *vr0, value_range *vr1);
/* Set of SSA names found live during the RPO traversal of the function
for still active basic-blocks. */
static sbitmap *live;
void
value_range::set_equiv (bitmap equiv)
value_range_equiv::set_equiv (bitmap equiv)
{
if (undefined_p () || varying_p ())
equiv = NULL;
@ -103,39 +103,39 @@ value_range::set_equiv (bitmap equiv)
/* Initialize value_range. */
void
value_range::set (enum value_range_kind kind, tree min, tree max,
bitmap equiv)
value_range_equiv::set (enum value_range_kind kind, tree min, tree max,
bitmap equiv)
{
value_range_base::set (kind, min, max);
value_range::set (kind, min, max);
set_equiv (equiv);
if (flag_checking)
check ();
}
value_range_base::value_range_base (value_range_kind kind, tree min, tree max)
value_range::value_range (value_range_kind kind, tree min, tree max)
{
set (kind, min, max);
}
value_range::value_range (value_range_kind kind, tree min, tree max,
bitmap equiv)
value_range_equiv::value_range_equiv (value_range_kind kind,
tree min, tree max, bitmap equiv)
{
m_equiv = NULL;
set (kind, min, max, equiv);
}
value_range::value_range (const value_range_base &other)
value_range_equiv::value_range_equiv (const value_range &other)
{
m_equiv = NULL;
set (other.kind (), other.min(), other.max (), NULL);
}
value_range_base::value_range_base (tree type)
value_range::value_range (tree type)
{
set_varying (type);
}
value_range_base::value_range_base (enum value_range_kind kind,
value_range::value_range (enum value_range_kind kind,
tree type,
const wide_int &wmin,
const wide_int &wmax)
@ -146,7 +146,7 @@ value_range_base::value_range_base (enum value_range_kind kind,
set (kind, min, max);
}
value_range_base::value_range_base (tree type,
value_range::value_range (tree type,
const wide_int &wmin,
const wide_int &wmax)
{
@ -155,7 +155,7 @@ value_range_base::value_range_base (tree type,
set (VR_RANGE, min, max);
}
value_range_base::value_range_base (tree min, tree max)
value_range::value_range (tree min, tree max)
{
set (VR_RANGE, min, max);
}
@ -163,7 +163,7 @@ value_range_base::value_range_base (tree min, tree max)
/* Like set, but keep the equivalences in place. */
void
value_range::update (value_range_kind kind, tree min, tree max)
value_range_equiv::update (value_range_kind kind, tree min, tree max)
{
set (kind, min, max,
(kind != VR_UNDEFINED && kind != VR_VARYING) ? m_equiv : NULL);
@ -176,13 +176,13 @@ value_range::update (value_range_kind kind, tree min, tree max)
object. Use the constructors for initialization. */
void
value_range::deep_copy (const value_range *from)
value_range_equiv::deep_copy (const value_range_equiv *from)
{
set (from->m_kind, from->min (), from->max (), from->m_equiv);
}
void
value_range::move (value_range *from)
value_range_equiv::move (value_range_equiv *from)
{
set (from->m_kind, from->min (), from->max ());
m_equiv = from->m_equiv;
@ -192,7 +192,7 @@ value_range::move (value_range *from)
/* Check the validity of the range. */
void
value_range_base::check ()
value_range::check ()
{
switch (m_kind)
{
@ -226,9 +226,9 @@ value_range_base::check ()
}
void
value_range::check ()
value_range_equiv::check ()
{
value_range_base::check ();
value_range::check ();
switch (m_kind)
{
case VR_UNDEFINED:
@ -243,7 +243,7 @@ value_range::check ()
class. */
bool
value_range_base::equal_p (const value_range_base &other) const
value_range::equal_p (const value_range &other) const
{
/* Ignore types for undefined. All undefines are equal. */
if (undefined_p ())
@ -270,9 +270,10 @@ vrp_bitmap_equal_p (const_bitmap b1, const_bitmap b2)
IGNORE_EQUIVS is TRUE. */
bool
value_range::equal_p (const value_range &other, bool ignore_equivs) const
value_range_equiv::equal_p (const value_range_equiv &other,
bool ignore_equivs) const
{
return (value_range_base::equal_p (other)
return (value_range::equal_p (other)
&& (ignore_equivs
|| vrp_bitmap_equal_p (m_equiv, other.m_equiv)));
}
@ -280,7 +281,7 @@ value_range::equal_p (const value_range &other, bool ignore_equivs) const
/* Return TRUE if this is a symbolic range. */
bool
value_range_base::symbolic_p () const
value_range::symbolic_p () const
{
return (!varying_p ()
&& !undefined_p ()
@ -294,7 +295,7 @@ value_range_base::symbolic_p () const
constants would be represented as [-MIN, +MAX]. */
bool
value_range_base::constant_p () const
value_range::constant_p () const
{
return (!varying_p ()
&& !undefined_p ()
@ -303,20 +304,20 @@ value_range_base::constant_p () const
}
void
value_range_base::set_undefined ()
value_range::set_undefined ()
{
m_kind = VR_UNDEFINED;
m_min = m_max = NULL;
}
void
value_range::set_undefined ()
value_range_equiv::set_undefined ()
{
set (VR_UNDEFINED, NULL, NULL, NULL);
}
void
value_range_base::set_varying (tree type)
value_range::set_varying (tree type)
{
m_kind = VR_VARYING;
if (supports_type_p (type))
@ -330,22 +331,22 @@ value_range_base::set_varying (tree type)
}
void
value_range::set_varying (tree type)
value_range_equiv::set_varying (tree type)
{
value_range_base::set_varying (type);
value_range::set_varying (type);
equiv_clear ();
}
/* Return TRUE if it is possible that range contains VAL. */
bool
value_range_base::may_contain_p (tree val) const
value_range::may_contain_p (tree val) const
{
return value_inside_range (val) != 0;
}
void
value_range::equiv_clear ()
value_range_equiv::equiv_clear ()
{
if (m_equiv)
bitmap_clear (m_equiv);
@ -359,9 +360,9 @@ value_range::equiv_clear ()
turned on/off. */
void
value_range::equiv_add (const_tree var,
const value_range *var_vr,
bitmap_obstack *obstack)
value_range_equiv::equiv_add (const_tree var,
const value_range_equiv *var_vr,
bitmap_obstack *obstack)
{
if (!m_equiv)
m_equiv = BITMAP_ALLOC (obstack);
@ -376,7 +377,7 @@ value_range::equiv_add (const_tree var,
So, [&x, &x] counts as a singleton. */
bool
value_range_base::singleton_p (tree *result) const
value_range::singleton_p (tree *result) const
{
if (m_kind == VR_ANTI_RANGE)
{
@ -392,7 +393,7 @@ value_range_base::singleton_p (tree *result) const
}
if (num_pairs () == 1)
{
value_range_base vr0, vr1;
value_range vr0, vr1;
ranges_from_anti_range (this, &vr0, &vr1);
return vr0.singleton_p (result);
}
@ -409,14 +410,14 @@ value_range_base::singleton_p (tree *result) const
}
tree
value_range_base::type () const
value_range::type () const
{
gcc_checking_assert (m_min);
return TREE_TYPE (min ());
}
void
value_range_base::dump (FILE *file) const
value_range::dump (FILE *file) const
{
if (undefined_p ())
fprintf (file, "UNDEFINED");
@ -458,15 +459,15 @@ value_range_base::dump (FILE *file) const
}
void
value_range_base::dump () const
value_range::dump () const
{
dump (stderr);
}
void
value_range::dump (FILE *file) const
value_range_equiv::dump (FILE *file) const
{
value_range_base::dump (file);
value_range::dump (file);
if ((m_kind == VR_RANGE || m_kind == VR_ANTI_RANGE)
&& m_equiv)
{
@ -487,11 +488,20 @@ value_range::dump (FILE *file) const
}
void
value_range::dump () const
value_range_equiv::dump () const
{
dump (stderr);
}
void
dump_value_range (FILE *file, const value_range_equiv *vr)
{
if (!vr)
fprintf (file, "[]");
else
vr->dump (file);
}
void
dump_value_range (FILE *file, const value_range *vr)
{
@ -501,27 +511,6 @@ dump_value_range (FILE *file, const value_range *vr)
vr->dump (file);
}
void
dump_value_range (FILE *file, const value_range_base *vr)
{
if (!vr)
fprintf (file, "[]");
else
vr->dump (file);
}
DEBUG_FUNCTION void
debug (const value_range_base *vr)
{
dump_value_range (stderr, vr);
}
DEBUG_FUNCTION void
debug (const value_range_base &vr)
{
dump_value_range (stderr, &vr);
}
DEBUG_FUNCTION void
debug (const value_range *vr)
{
@ -534,6 +523,18 @@ debug (const value_range &vr)
dump_value_range (stderr, &vr);
}
DEBUG_FUNCTION void
debug (const value_range_equiv *vr)
{
dump_value_range (stderr, vr);
}
DEBUG_FUNCTION void
debug (const value_range_equiv &vr)
{
dump_value_range (stderr, &vr);
}
/* Return true if the SSA name NAME is live on the edge E. */
static bool
@ -717,7 +718,7 @@ intersect_range_with_nonzero_bits (enum value_range_kind vr_type,
extract ranges from var + CST op limit. */
void
value_range_base::set (enum value_range_kind kind, tree min, tree max)
value_range::set (enum value_range_kind kind, tree min, tree max)
{
/* Use the canonical setters for VR_UNDEFINED and VR_VARYING. */
if (kind == VR_UNDEFINED)
@ -876,7 +877,7 @@ value_range_base::set (enum value_range_kind kind, tree min, tree max)
}
void
value_range_base::set (tree val)
value_range::set (tree val)
{
gcc_assert (TREE_CODE (val) == SSA_NAME || is_gimple_min_invariant (val));
if (TREE_OVERFLOW_P (val))
@ -885,7 +886,7 @@ value_range_base::set (tree val)
}
void
value_range::set (tree val)
value_range_equiv::set (tree val)
{
gcc_assert (TREE_CODE (val) == SSA_NAME || is_gimple_min_invariant (val));
if (TREE_OVERFLOW_P (val))
@ -896,7 +897,7 @@ value_range::set (tree val)
/* Set value range VR to a nonzero range of type TYPE. */
void
value_range_base::set_nonzero (tree type)
value_range::set_nonzero (tree type)
{
tree zero = build_int_cst (type, 0);
set (VR_ANTI_RANGE, zero, zero);
@ -905,7 +906,7 @@ value_range_base::set_nonzero (tree type)
/* Set value range VR to a ZERO range of type TYPE. */
void
value_range_base::set_zero (tree type)
value_range::set_zero (tree type)
{
set (build_int_cst (type, 0));
}
@ -923,7 +924,7 @@ vrp_operand_equal_p (const_tree val1, const_tree val2)
}
static bool
range_has_numeric_bounds_p (const value_range_base *vr)
range_has_numeric_bounds_p (const value_range *vr)
{
return (vr->min ()
&& TREE_CODE (vr->min ()) == INTEGER_CST
@ -934,7 +935,7 @@ range_has_numeric_bounds_p (const value_range_base *vr)
a singleton. */
bool
range_int_cst_p (const value_range_base *vr)
range_int_cst_p (const value_range *vr)
{
return (vr->kind () == VR_RANGE && range_has_numeric_bounds_p (vr));
}
@ -1234,7 +1235,7 @@ compare_values (tree val1, tree val2)
function. */
int
value_range_base::value_inside_range (tree val) const
value_range::value_inside_range (tree val) const
{
int cmp1, cmp2;
@ -1266,8 +1267,8 @@ value_range_base::value_inside_range (tree val) const
*VR1 will be VR_UNDEFINED. */
static bool
ranges_from_anti_range (const value_range_base *ar,
value_range_base *vr0, value_range_base *vr1)
ranges_from_anti_range (const value_range *ar,
value_range *vr0, value_range *vr1)
{
tree type = ar->type ();
@ -1488,11 +1489,11 @@ set_value_range_with_overflow (value_range_kind &kind, tree &min, tree &max,
/* Fold two value range's of a POINTER_PLUS_EXPR into VR. */
static void
extract_range_from_pointer_plus_expr (value_range_base *vr,
extract_range_from_pointer_plus_expr (value_range *vr,
enum tree_code code,
tree expr_type,
const value_range_base *vr0,
const value_range_base *vr1)
const value_range *vr0,
const value_range *vr1)
{
gcc_checking_assert (POINTER_TYPE_P (expr_type)
&& code == POINTER_PLUS_EXPR);
@ -1528,16 +1529,16 @@ extract_range_from_pointer_plus_expr (value_range_base *vr,
result in *VR. */
static void
extract_range_from_plus_minus_expr (value_range_base *vr,
extract_range_from_plus_minus_expr (value_range *vr,
enum tree_code code,
tree expr_type,
const value_range_base *vr0_,
const value_range_base *vr1_)
const value_range *vr0_,
const value_range *vr1_)
{
gcc_checking_assert (code == PLUS_EXPR || code == MINUS_EXPR);
value_range_base vr0 = *vr0_, vr1 = *vr1_;
value_range_base vrtem0, vrtem1;
value_range vr0 = *vr0_, vr1 = *vr1_;
value_range vrtem0, vrtem1;
/* Now canonicalize anti-ranges to ranges when they are not symbolic
and express ~[] op X as ([]' op X) U ([]'' op X). */
@ -1547,7 +1548,7 @@ extract_range_from_plus_minus_expr (value_range_base *vr,
extract_range_from_plus_minus_expr (vr, code, expr_type, &vrtem0, vr1_);
if (!vrtem1.undefined_p ())
{
value_range_base vrres;
value_range vrres;
extract_range_from_plus_minus_expr (&vrres, code, expr_type,
&vrtem1, vr1_);
vr->union_ (&vrres);
@ -1561,7 +1562,7 @@ extract_range_from_plus_minus_expr (value_range_base *vr,
extract_range_from_plus_minus_expr (vr, code, expr_type, vr0_, &vrtem0);
if (!vrtem1.undefined_p ())
{
value_range_base vrres;
value_range vrres;
extract_range_from_plus_minus_expr (&vrres, code, expr_type,
vr0_, &vrtem1);
vr->union_ (&vrres);
@ -1710,7 +1711,7 @@ extract_range_from_plus_minus_expr (value_range_base *vr,
suitable operator is found, return NULL and set VR to VARYING. */
static const range_operator *
get_range_op_handler (value_range_base *vr,
get_range_op_handler (value_range *vr,
enum tree_code code,
tree expr_type)
{
@ -1724,12 +1725,12 @@ get_range_op_handler (value_range_base *vr,
VARYING and return FALSE. */
static bool
supported_types_p (value_range_base *vr,
supported_types_p (value_range *vr,
tree type0,
tree type1 = NULL)
{
if (!value_range_base::supports_type_p (type0)
|| (type1 && !value_range_base::supports_type_p (type1)))
if (!value_range::supports_type_p (type0)
|| (type1 && !value_range::supports_type_p (type1)))
{
vr->set_varying (type0);
return false;
@ -1741,9 +1742,9 @@ supported_types_p (value_range_base *vr,
VR to UNDEFINED and return FALSE. */
static bool
defined_ranges_p (value_range_base *vr,
const value_range_base *vr0,
const value_range_base *vr1 = NULL)
defined_ranges_p (value_range *vr,
const value_range *vr0,
const value_range *vr1 = NULL)
{
if (vr0->undefined_p () && (!vr1 || vr1->undefined_p ()))
{
@ -1753,11 +1754,11 @@ defined_ranges_p (value_range_base *vr,
return true;
}
static value_range_base
drop_undefines_to_varying (const value_range_base *vr, tree expr_type)
static value_range
drop_undefines_to_varying (const value_range *vr, tree expr_type)
{
if (vr->undefined_p ())
return value_range_base (expr_type);
return value_range (expr_type);
else
return *vr;
}
@ -1766,11 +1767,11 @@ drop_undefines_to_varying (const value_range_base *vr, tree expr_type)
return TRUE, otherwise return FALSE. */
static bool
range_fold_binary_symbolics_p (value_range_base *vr,
range_fold_binary_symbolics_p (value_range *vr,
tree_code code,
tree expr_type,
const value_range_base *vr0,
const value_range_base *vr1)
const value_range *vr0,
const value_range *vr1)
{
if (vr0->symbolic_p () || vr1->symbolic_p ())
{
@ -1797,17 +1798,17 @@ range_fold_binary_symbolics_p (value_range_base *vr,
TRUE, otherwise return FALSE. */
static bool
range_fold_unary_symbolics_p (value_range_base *vr,
range_fold_unary_symbolics_p (value_range *vr,
tree_code code,
tree expr_type,
const value_range_base *vr0)
const value_range *vr0)
{
if (vr0->symbolic_p ())
{
if (code == NEGATE_EXPR)
{
/* -X is simply 0 - X. */
value_range_base zero;
value_range zero;
zero.set_zero (vr0->type ());
range_fold_binary_expr (vr, MINUS_EXPR, expr_type, &zero, vr0);
return true;
@ -1815,7 +1816,7 @@ range_fold_unary_symbolics_p (value_range_base *vr,
if (code == BIT_NOT_EXPR)
{
/* ~X is simply -1 - X. */
value_range_base minusone;
value_range minusone;
minusone.set (build_int_cst (vr0->type (), -1));
range_fold_binary_expr (vr, MINUS_EXPR, expr_type, &minusone, vr0);
return true;
@ -1823,7 +1824,7 @@ range_fold_unary_symbolics_p (value_range_base *vr,
const range_operator *op = get_range_op_handler (vr, code, expr_type);
*vr = op->fold_range (expr_type,
vr0->normalize_symbolics (),
value_range_base (expr_type));
value_range (expr_type));
return true;
}
return false;
@ -1832,11 +1833,11 @@ range_fold_unary_symbolics_p (value_range_base *vr,
/* Perform a binary operation on a pair of ranges. */
void
range_fold_binary_expr (value_range_base *vr,
range_fold_binary_expr (value_range *vr,
enum tree_code code,
tree expr_type,
const value_range_base *vr0_,
const value_range_base *vr1_)
const value_range *vr0_,
const value_range *vr1_)
{
if (!supported_types_p (vr, expr_type)
|| !defined_ranges_p (vr, vr0_, vr1_))
@ -1845,8 +1846,8 @@ range_fold_binary_expr (value_range_base *vr,
if (!op)
return;
value_range_base vr0 = drop_undefines_to_varying (vr0_, expr_type);
value_range_base vr1 = drop_undefines_to_varying (vr1_, expr_type);
value_range vr0 = drop_undefines_to_varying (vr0_, expr_type);
value_range vr1 = drop_undefines_to_varying (vr1_, expr_type);
if (range_fold_binary_symbolics_p (vr, code, expr_type, &vr0, &vr1))
return;
@ -1858,9 +1859,9 @@ range_fold_binary_expr (value_range_base *vr,
/* Perform a unary operation on a range. */
void
range_fold_unary_expr (value_range_base *vr,
range_fold_unary_expr (value_range *vr,
enum tree_code code, tree expr_type,
const value_range_base *vr0,
const value_range *vr0,
tree vr0_type)
{
if (!supported_types_p (vr, expr_type, vr0_type)
@ -1875,7 +1876,7 @@ range_fold_unary_expr (value_range_base *vr,
*vr = op->fold_range (expr_type,
vr0->normalize_addresses (),
value_range_base (expr_type));
value_range (expr_type));
}
/* Given a COND_EXPR COND of the form 'V OP W', and an SSA name V,
@ -4054,20 +4055,20 @@ class vrp_prop : public ssa_propagation_engine
class vr_values vr_values;
/* Temporary delegator to minimize code churn. */
const value_range *get_value_range (const_tree op)
const value_range_equiv *get_value_range (const_tree op)
{ return vr_values.get_value_range (op); }
void set_def_to_varying (const_tree def)
{ vr_values.set_def_to_varying (def); }
void set_defs_to_varying (gimple *stmt)
{ vr_values.set_defs_to_varying (stmt); }
void extract_range_from_stmt (gimple *stmt, edge *taken_edge_p,
tree *output_p, value_range *vr)
tree *output_p, value_range_equiv *vr)
{ vr_values.extract_range_from_stmt (stmt, taken_edge_p, output_p, vr); }
bool update_value_range (const_tree op, value_range *vr)
bool update_value_range (const_tree op, value_range_equiv *vr)
{ return vr_values.update_value_range (op, vr); }
void extract_range_basic (value_range *vr, gimple *stmt)
void extract_range_basic (value_range_equiv *vr, gimple *stmt)
{ vr_values.extract_range_basic (vr, stmt); }
void extract_range_from_phi_node (gphi *phi, value_range *vr)
void extract_range_from_phi_node (gphi *phi, value_range_equiv *vr)
{ vr_values.extract_range_from_phi_node (phi, vr); }
};
/* Checks one ARRAY_REF in REF, located at LOCUS. Ignores flexible arrays
@ -4159,7 +4160,7 @@ vrp_prop::check_array_ref (location_t location, tree ref,
"array subscript %E is above array bounds of %qT",
low_bound, artype);
const value_range *vr = NULL;
const value_range_equiv *vr = NULL;
if (TREE_CODE (low_sub) == SSA_NAME)
{
vr = get_value_range (low_sub);
@ -4285,7 +4286,7 @@ vrp_prop::check_mem_ref (location_t location, tree ref,
/* The range of the byte offset into the reference. */
offset_int offrange[2] = { 0, 0 };
const value_range *vr = NULL;
const value_range_equiv *vr = NULL;
/* Determine the offsets and increment OFFRANGE for the bounds of each.
The loop computes the range of the final offset for expressions such
@ -5124,7 +5125,7 @@ enum ssa_prop_result
vrp_prop::visit_stmt (gimple *stmt, edge *taken_edge_p, tree *output_p)
{
tree lhs = gimple_get_lhs (stmt);
value_range vr;
value_range_equiv vr;
extract_range_from_stmt (stmt, taken_edge_p, output_p, &vr);
if (*output_p)
@ -5193,9 +5194,9 @@ vrp_prop::visit_stmt (gimple *stmt, edge *taken_edge_p, tree *output_p)
SSA_PROP_NOT_INTERESTING. If there are no
{REAL,IMAG}PART_EXPR uses at all,
return SSA_PROP_VARYING. */
value_range new_vr;
value_range_equiv new_vr;
extract_range_basic (&new_vr, use_stmt);
const value_range *old_vr = get_value_range (use_lhs);
const value_range_equiv *old_vr = get_value_range (use_lhs);
if (!old_vr->equal_p (new_vr, /*ignore_equivs=*/false))
res = SSA_PROP_INTERESTING;
else
@ -5825,9 +5826,9 @@ intersect_ranges (enum value_range_kind *vr0type,
value ranges VR0 and VR1, return the intersection of the two
ranges. This may not be the smallest possible such range. */
value_range_base
value_range_base::intersect_helper (const value_range_base *vr0,
const value_range_base *vr1)
value_range
value_range::intersect_helper (const value_range *vr0,
const value_range *vr1)
{
/* If either range is VR_VARYING the other one wins. */
if (vr1->varying_p ())
@ -5850,7 +5851,7 @@ value_range_base::intersect_helper (const value_range_base *vr0,
/* Make sure to canonicalize the result though as the inversion of a
VR_RANGE can still be a VR_RANGE. Work on a temporary so we can
fall back to vr0 when this turns things to varying. */
value_range_base tem;
value_range tem;
if (vr0type == VR_UNDEFINED)
tem.set_undefined ();
else if (vr0type == VR_VARYING)
@ -5865,7 +5866,7 @@ value_range_base::intersect_helper (const value_range_base *vr0,
}
void
value_range_base::intersect (const value_range_base *other)
value_range::intersect (const value_range *other)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@ -5887,7 +5888,7 @@ value_range_base::intersect (const value_range_base *other)
}
void
value_range::intersect (const value_range *other)
value_range_equiv::intersect (const value_range_equiv *other)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@ -5905,7 +5906,7 @@ value_range::intersect (const value_range *other)
this->deep_copy (other);
else
{
value_range_base tem = intersect_helper (this, other);
value_range tem = intersect_helper (this, other);
this->update (tem.kind (), tem.min (), tem.max ());
/* If the result is VR_UNDEFINED there is no need to mess with
@ -5939,9 +5940,9 @@ value_range::intersect (const value_range *other)
VR1, return a range that contains both VR0 and VR1. This may not be the
smallest possible such range. */
value_range_base
value_range_base::union_helper (const value_range_base *vr0,
const value_range_base *vr1)
value_range
value_range::union_helper (const value_range *vr0,
const value_range *vr1)
{
/* VR0 has the resulting range if VR1 is undefined or VR0 is varying. */
if (vr1->undefined_p ()
@ -5960,7 +5961,7 @@ value_range_base::union_helper (const value_range_base *vr0,
vr1->kind (), vr1->min (), vr1->max ());
/* Work on a temporary so we can still use vr0 when union returns varying. */
value_range_base tem;
value_range tem;
if (vr0type == VR_UNDEFINED)
tem.set_undefined ();
else if (vr0type == VR_VARYING)
@ -5988,7 +5989,7 @@ value_range_base::union_helper (const value_range_base *vr0,
may not be the smallest possible such range. */
void
value_range_base::union_ (const value_range_base *other)
value_range::union_ (const value_range *other)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@ -6010,7 +6011,7 @@ value_range_base::union_ (const value_range_base *other)
}
void
value_range::union_ (const value_range *other)
value_range_equiv::union_ (const value_range_equiv *other)
{
if (dump_file && (dump_flags & TDF_DETAILS))
{
@ -6027,7 +6028,7 @@ value_range::union_ (const value_range *other)
this->deep_copy (other);
else
{
value_range_base tem = union_helper (this, other);
value_range tem = union_helper (this, other);
this->update (tem.kind (), tem.min (), tem.max ());
/* The resulting set of equivalences is always the intersection of
@ -6048,8 +6049,8 @@ value_range::union_ (const value_range *other)
/* Normalize addresses into constants. */
value_range_base
value_range_base::normalize_addresses () const
value_range
value_range::normalize_addresses () const
{
if (undefined_p ())
return *this;
@ -6063,13 +6064,13 @@ value_range_base::normalize_addresses () const
|| TREE_CODE (m_max) == ADDR_EXPR);
return range_nonzero (type ());
}
return value_range_base (type ());
return value_range (type ());
}
/* Normalize symbolics and addresses into constants. */
value_range_base
value_range_base::normalize_symbolics () const
value_range
value_range::normalize_symbolics () const
{
if (varying_p () || undefined_p ())
return *this;
@ -6082,7 +6083,7 @@ value_range_base::normalize_symbolics () const
// [SYM, SYM] -> VARYING
if (min_symbolic && max_symbolic)
{
value_range_base var;
value_range var;
var.set_varying (ttype);
return var;
}
@ -6090,9 +6091,9 @@ value_range_base::normalize_symbolics () const
{
// [SYM, NUM] -> [-MIN, NUM]
if (min_symbolic)
return value_range_base (VR_RANGE, vrp_val_min (ttype), max ());
return value_range (VR_RANGE, vrp_val_min (ttype), max ());
// [NUM, SYM] -> [NUM, +MAX]
return value_range_base (VR_RANGE, min (), vrp_val_max (ttype));
return value_range (VR_RANGE, min (), vrp_val_max (ttype));
}
gcc_checking_assert (kind () == VR_ANTI_RANGE);
// ~[SYM, NUM] -> [NUM + 1, +MAX]
@ -6101,9 +6102,9 @@ value_range_base::normalize_symbolics () const
if (!vrp_val_is_max (max ()))
{
tree n = wide_int_to_tree (ttype, wi::to_wide (max ()) + 1);
return value_range_base (VR_RANGE, n, vrp_val_max (ttype));
return value_range (VR_RANGE, n, vrp_val_max (ttype));
}
value_range_base var;
value_range var;
var.set_varying (ttype);
return var;
}
@ -6111,9 +6112,9 @@ value_range_base::normalize_symbolics () const
if (!vrp_val_is_min (min ()))
{
tree n = wide_int_to_tree (ttype, wi::to_wide (min ()) - 1);
return value_range_base (VR_RANGE, vrp_val_min (ttype), n);
return value_range (VR_RANGE, vrp_val_min (ttype), n);
}
value_range_base var;
value_range var;
var.set_varying (ttype);
return var;
}
@ -6121,7 +6122,7 @@ value_range_base::normalize_symbolics () const
/* Return the number of sub-ranges in a range. */
unsigned
value_range_base::num_pairs () const
value_range::num_pairs () const
{
if (undefined_p ())
return 0;
@ -6144,7 +6145,7 @@ value_range_base::num_pairs () const
question. */
wide_int
value_range_base::lower_bound (unsigned pair) const
value_range::lower_bound (unsigned pair) const
{
if (symbolic_p ())
return normalize_symbolics ().lower_bound (pair);
@ -6169,7 +6170,7 @@ value_range_base::lower_bound (unsigned pair) const
question. */
wide_int
value_range_base::upper_bound (unsigned pair) const
value_range::upper_bound (unsigned pair) const
{
if (symbolic_p ())
return normalize_symbolics ().upper_bound (pair);
@ -6193,7 +6194,7 @@ value_range_base::upper_bound (unsigned pair) const
/* Return the highest bound in a range. */
wide_int
value_range_base::upper_bound () const
value_range::upper_bound () const
{
unsigned pairs = num_pairs ();
gcc_checking_assert (pairs > 0);
@ -6203,7 +6204,7 @@ value_range_base::upper_bound () const
/* Return TRUE if range contains INTEGER_CST. */
bool
value_range_base::contains_p (tree cst) const
value_range::contains_p (tree cst) const
{
gcc_checking_assert (TREE_CODE (cst) == INTEGER_CST);
if (symbolic_p ())
@ -6214,14 +6215,14 @@ value_range_base::contains_p (tree cst) const
/* Return the inverse of a range. */
void
value_range_base::invert ()
value_range::invert ()
{
/* We can't just invert VR_RANGE and VR_ANTI_RANGE because we may
create non-canonical ranges. Use the constructors instead. */
if (m_kind == VR_RANGE)
*this = value_range_base (VR_ANTI_RANGE, m_min, m_max);
*this = value_range (VR_ANTI_RANGE, m_min, m_max);
else if (m_kind == VR_ANTI_RANGE)
*this = value_range_base (VR_RANGE, m_min, m_max);
*this = value_range (VR_RANGE, m_min, m_max);
else
gcc_unreachable ();
}
@ -6229,7 +6230,7 @@ value_range_base::invert ()
/* Range union, but for references. */
void
value_range_base::union_ (const value_range_base &r)
value_range::union_ (const value_range &r)
{
/* Disable details for now, because it makes the ranger dump
unnecessarily verbose. */
@ -6244,7 +6245,7 @@ value_range_base::union_ (const value_range_base &r)
/* Range intersect, but for references. */
void
value_range_base::intersect (const value_range_base &r)
value_range::intersect (const value_range &r)
{
/* Disable details for now, because it makes the ranger dump
unnecessarily verbose. */
@ -6257,7 +6258,7 @@ value_range_base::intersect (const value_range_base &r)
}
bool
value_range_base::operator== (const value_range_base &r) const
value_range::operator== (const value_range &r) const
{
return equal_p (r);
}
@ -6270,7 +6271,7 @@ enum ssa_prop_result
vrp_prop::visit_phi (gphi *phi)
{
tree lhs = PHI_RESULT (phi);
value_range vr_result;
value_range_equiv vr_result;
extract_range_from_phi_node (phi, &vr_result);
if (update_value_range (lhs, &vr_result))
{
@ -6467,7 +6468,7 @@ simplify_stmt_for_jump_threading (gimple *stmt, gimple *within_stmt,
op = lhs_of_dominating_assert (op, bb, stmt);
const value_range *vr = vr_values->get_value_range (op);
const value_range_equiv *vr = vr_values->get_value_range (op);
if (vr->undefined_p ()
|| vr->varying_p ()
|| vr->symbolic_p ())
@ -6533,7 +6534,7 @@ simplify_stmt_for_jump_threading (gimple *stmt, gimple *within_stmt,
{
edge dummy_e;
tree dummy_tree;
value_range new_vr;
value_range_equiv new_vr;
vr_values->extract_range_from_stmt (stmt, &dummy_e,
&dummy_tree, &new_vr);
tree singleton;
@ -6709,7 +6710,7 @@ vrp_prop::vrp_finalize (bool warn_array_bounds_p)
if (!name)
continue;
const value_range *vr = get_value_range (name);
const value_range_equiv *vr = get_value_range (name);
if (!name || !vr->constant_p ())
continue;
@ -6905,11 +6906,11 @@ make_pass_vrp (gcc::context *ctxt)
/* Worker for determine_value_range. */
static void
determine_value_range_1 (value_range_base *vr, tree expr)
determine_value_range_1 (value_range *vr, tree expr)
{
if (BINARY_CLASS_P (expr))
{
value_range_base vr0, vr1;
value_range vr0, vr1;
determine_value_range_1 (&vr0, TREE_OPERAND (expr, 0));
determine_value_range_1 (&vr1, TREE_OPERAND (expr, 1));
range_fold_binary_expr (vr, TREE_CODE (expr), TREE_TYPE (expr),
@ -6917,7 +6918,7 @@ determine_value_range_1 (value_range_base *vr, tree expr)
}
else if (UNARY_CLASS_P (expr))
{
value_range_base vr0;
value_range vr0;
determine_value_range_1 (&vr0, TREE_OPERAND (expr, 0));
range_fold_unary_expr (vr, TREE_CODE (expr), TREE_TYPE (expr),
&vr0, TREE_TYPE (TREE_OPERAND (expr, 0)));
@ -6946,7 +6947,7 @@ determine_value_range_1 (value_range_base *vr, tree expr)
value_range_kind
determine_value_range (tree expr, wide_int *min, wide_int *max)
{
value_range_base vr;
value_range vr;
determine_value_range_1 (&vr, expr);
if (vr.constant_p ())
{

View file

@ -37,17 +37,17 @@ enum value_range_kind
/* Range of values that can be associated with an SSA_NAME after VRP
has executed. */
class GTY((for_user)) value_range_base
class GTY((for_user)) value_range
{
friend void range_tests ();
public:
value_range_base ();
value_range_base (value_range_kind, tree, tree);
value_range_base (tree, tree);
value_range_base (value_range_kind,
tree type, const wide_int &, const wide_int &);
value_range_base (tree type, const wide_int &, const wide_int &);
value_range_base (tree type);
value_range ();
value_range (value_range_kind, tree, tree);
value_range (tree, tree);
value_range (value_range_kind,
tree type, const wide_int &, const wide_int &);
value_range (tree type, const wide_int &, const wide_int &);
value_range (tree type);
void set (value_range_kind, tree, tree);
void set (tree);
@ -66,14 +66,14 @@ public:
void set_varying (tree type);
void set_undefined ();
void union_ (const value_range_base *);
void intersect (const value_range_base *);
void union_ (const value_range_base &);
void intersect (const value_range_base &);
void union_ (const value_range *);
void intersect (const value_range *);
void union_ (const value_range &);
void intersect (const value_range &);
bool operator== (const value_range_base &) const;
bool operator!= (const value_range_base &) const /* = delete */;
bool equal_p (const value_range_base &) const;
bool operator== (const value_range &) const;
bool operator!= (const value_range &) const /* = delete */;
bool equal_p (const value_range &) const;
/* Misc methods. */
tree type () const;
@ -85,8 +85,8 @@ public:
void dump () const;
static bool supports_type_p (tree);
value_range_base normalize_symbolics () const;
value_range_base normalize_addresses () const;
value_range normalize_symbolics () const;
value_range normalize_addresses () const;
static const unsigned int m_max_pairs = 2;
bool contains_p (tree) const;
@ -98,46 +98,45 @@ public:
protected:
void check ();
static value_range_base union_helper (const value_range_base *,
const value_range_base *);
static value_range_base intersect_helper (const value_range_base *,
const value_range_base *);
static value_range union_helper (const value_range *, const value_range *);
static value_range intersect_helper (const value_range *,
const value_range *);
enum value_range_kind m_kind;
tree m_min;
tree m_max;
friend void gt_ggc_mx_value_range_base (void *);
friend void gt_pch_p_16value_range_base (void *, void *,
gt_pointer_operator, void *);
friend void gt_pch_nx_value_range_base (void *);
friend void gt_ggc_mx (value_range_base &);
friend void gt_ggc_mx (value_range_base *&);
friend void gt_pch_nx (value_range_base &);
friend void gt_pch_nx (value_range_base *, gt_pointer_operator, void *);
friend void gt_ggc_mx_value_range (void *);
friend void gt_pch_p_11value_range (void *, void *,
gt_pointer_operator, void *);
friend void gt_pch_nx_value_range (void *);
friend void gt_ggc_mx (value_range &);
friend void gt_ggc_mx (value_range *&);
friend void gt_pch_nx (value_range &);
friend void gt_pch_nx (value_range *, gt_pointer_operator, void *);
private:
int value_inside_range (tree) const;
};
/* Note value_range cannot currently be used with GC memory, only
value_range_base is fully set up for this. */
class GTY((user)) value_range : public value_range_base
/* Note value_range_equiv cannot currently be used with GC memory,
only value_range is fully set up for this. */
class GTY((user)) value_range_equiv : public value_range
{
public:
value_range ();
value_range (const value_range_base &);
value_range_equiv ();
value_range_equiv (const value_range &);
/* Deep-copies equiv bitmap argument. */
value_range (value_range_kind, tree, tree, bitmap = NULL);
value_range_equiv (value_range_kind, tree, tree, bitmap = NULL);
/* Shallow-copies equiv bitmap. */
value_range (const value_range &) /* = delete */;
value_range_equiv (const value_range_equiv &) /* = delete */;
/* Shallow-copies equiv bitmap. */
value_range& operator=(const value_range&) /* = delete */;
value_range_equiv& operator=(const value_range_equiv &) /* = delete */;
/* Move equiv bitmap from source range. */
void move (value_range *);
void move (value_range_equiv *);
/* Leaves equiv bitmap alone. */
void update (value_range_kind, tree, tree);
@ -145,11 +144,11 @@ class GTY((user)) value_range : public value_range_base
void set (value_range_kind, tree, tree, bitmap = NULL);
void set (tree);
bool operator== (const value_range &) const /* = delete */;
bool operator!= (const value_range &) const /* = delete */;
void intersect (const value_range *);
void union_ (const value_range *);
bool equal_p (const value_range &, bool ignore_equivs) const;
bool operator== (const value_range_equiv &) const /* = delete */;
bool operator!= (const value_range_equiv &) const /* = delete */;
void intersect (const value_range_equiv *);
void union_ (const value_range_equiv *);
bool equal_p (const value_range_equiv &, bool ignore_equivs) const;
/* Types of value ranges. */
void set_undefined ();
@ -158,10 +157,11 @@ class GTY((user)) value_range : public value_range_base
/* Equivalence bitmap methods. */
bitmap equiv () const;
void equiv_clear ();
void equiv_add (const_tree, const value_range *, bitmap_obstack * = NULL);
void equiv_add (const_tree, const value_range_equiv *,
bitmap_obstack * = NULL);
/* Misc methods. */
void deep_copy (const value_range *);
void deep_copy (const value_range_equiv *);
void dump (FILE *) const;
void dump () const;
@ -176,15 +176,15 @@ class GTY((user)) value_range : public value_range_base
};
inline
value_range_base::value_range_base ()
value_range::value_range ()
{
m_kind = VR_UNDEFINED;
m_min = m_max = NULL;
}
inline
value_range::value_range ()
: value_range_base ()
value_range_equiv::value_range_equiv ()
: value_range ()
{
m_equiv = NULL;
}
@ -192,13 +192,13 @@ value_range::value_range ()
/* Return the kind of this range. */
inline value_range_kind
value_range_base::kind () const
value_range::kind () const
{
return m_kind;
}
inline bitmap
value_range::equiv () const
value_range_equiv::equiv () const
{
return m_equiv;
}
@ -206,7 +206,7 @@ value_range::equiv () const
/* Return the lower bound. */
inline tree
value_range_base::min () const
value_range::min () const
{
return m_min;
}
@ -214,7 +214,7 @@ value_range_base::min () const
/* Return the upper bound. */
inline tree
value_range_base::max () const
value_range::max () const
{
return m_max;
}
@ -222,7 +222,7 @@ value_range_base::max () const
/* Return TRUE if range spans the entire possible domain. */
inline bool
value_range_base::varying_p () const
value_range::varying_p () const
{
return m_kind == VR_VARYING;
}
@ -230,7 +230,7 @@ value_range_base::varying_p () const
/* Return TRUE if range is undefined (essentially the empty set). */
inline bool
value_range_base::undefined_p () const
value_range::undefined_p () const
{
return m_kind == VR_UNDEFINED;
}
@ -238,15 +238,15 @@ value_range_base::undefined_p () const
/* Return TRUE if range is the constant zero. */
inline bool
value_range_base::zero_p () const
value_range::zero_p () const
{
return (m_kind == VR_RANGE
&& integer_zerop (m_min)
&& integer_zerop (m_max));
}
extern void dump_value_range (FILE *, const value_range_equiv *);
extern void dump_value_range (FILE *, const value_range *);
extern void dump_value_range (FILE *, const value_range_base *);
struct assert_info
{
@ -267,7 +267,7 @@ struct assert_info
// Otherwise return FALSE.
inline bool
value_range_base::supports_type_p (tree type)
value_range::supports_type_p (tree type)
{
if (type && (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type)))
return type;
@ -279,7 +279,7 @@ extern void register_edge_assert_for (tree, edge, enum tree_code,
extern bool stmt_interesting_for_vrp (gimple *);
extern bool infer_value_range (gimple *, tree, tree_code *, tree *);
extern bool range_int_cst_p (const value_range_base *);
extern bool range_int_cst_p (const value_range *);
extern int compare_values (tree, tree);
extern int compare_values_warnv (tree, tree, bool *);
@ -290,11 +290,11 @@ extern bool vrp_val_is_max (const_tree);
extern tree vrp_val_min (const_tree);
extern tree vrp_val_max (const_tree);
void range_fold_unary_expr (value_range_base *, enum tree_code, tree type,
const value_range_base *, tree op0_type);
void range_fold_binary_expr (value_range_base *, enum tree_code, tree type,
const value_range_base *,
const value_range_base *);
void range_fold_unary_expr (value_range *, enum tree_code, tree type,
const value_range *, tree op0_type);
void range_fold_binary_expr (value_range *, enum tree_code, tree type,
const value_range *,
const value_range *);
extern bool vrp_operand_equal_p (const_tree, const_tree);
extern enum value_range_kind intersect_range_with_nonzero_bits
@ -310,7 +310,7 @@ extern value_range_kind determine_value_range (tree, wide_int *, wide_int *);
/* Return TRUE if range is nonzero. */
inline bool
value_range_base::nonzero_p () const
value_range::nonzero_p () const
{
if (m_kind == VR_ANTI_RANGE
&& !TYPE_UNSIGNED (type ())
@ -327,7 +327,7 @@ value_range_base::nonzero_p () const
/* Return TRUE if *VR includes the value zero. */
inline bool
range_includes_zero_p (const value_range_base *vr)
range_includes_zero_p (const value_range *vr)
{
if (vr->undefined_p ())
return false;

View file

@ -54,7 +54,7 @@ along with GCC; see the file COPYING3. If not see
/* Set value range VR to a non-negative range of type TYPE. */
static inline void
set_value_range_to_nonnegative (value_range *vr, tree type)
set_value_range_to_nonnegative (value_range_equiv *vr, tree type)
{
tree zero = build_int_cst (type, 0);
vr->update (VR_RANGE, zero, vrp_val_max (type));
@ -63,7 +63,7 @@ set_value_range_to_nonnegative (value_range *vr, tree type)
/* Set value range VR to a range of a truthvalue of type TYPE. */
static inline void
set_value_range_to_truthvalue (value_range *vr, tree type)
set_value_range_to_truthvalue (value_range_equiv *vr, tree type)
{
if (TYPE_PRECISION (type) == 1)
vr->set_varying (type);
@ -74,10 +74,10 @@ set_value_range_to_truthvalue (value_range *vr, tree type)
/* Return the lattice entry for VAR or NULL if it doesn't exist or cannot
be initialized. */
value_range *
value_range_equiv *
vr_values::get_lattice_entry (const_tree var)
{
value_range *vr;
value_range_equiv *vr;
tree sym;
unsigned ver = SSA_NAME_VERSION (var);
@ -145,21 +145,21 @@ vr_values::get_lattice_entry (const_tree var)
If we have no values ranges recorded (ie, VRP is not running), then
return NULL. Otherwise create an empty range if none existed for VAR. */
const value_range *
const value_range_equiv *
vr_values::get_value_range (const_tree var)
{
/* If we have no recorded ranges, then return NULL. */
if (!vr_value)
return NULL;
value_range *vr = get_lattice_entry (var);
value_range_equiv *vr = get_lattice_entry (var);
/* Reallocate the lattice if needed. */
if (!vr)
{
unsigned int old_sz = num_vr_values;
num_vr_values = num_ssa_names + num_ssa_names / 10;
vr_value = XRESIZEVEC (value_range *, vr_value, num_vr_values);
vr_value = XRESIZEVEC (value_range_equiv *, vr_value, num_vr_values);
for ( ; old_sz < num_vr_values; old_sz++)
vr_value [old_sz] = NULL;
@ -176,7 +176,7 @@ vr_values::get_value_range (const_tree var)
void
vr_values::set_def_to_varying (const_tree def)
{
value_range *vr = get_lattice_entry (def);
value_range_equiv *vr = get_lattice_entry (def);
if (vr)
vr->set_varying (TREE_TYPE (def));
}
@ -203,18 +203,18 @@ vr_values::set_defs_to_varying (gimple *stmt)
is the range object associated with another SSA name. */
bool
vr_values::update_value_range (const_tree var, value_range *new_vr)
vr_values::update_value_range (const_tree var, value_range_equiv *new_vr)
{
value_range *old_vr;
value_range_equiv *old_vr;
bool is_new;
/* If there is a value-range on the SSA name from earlier analysis
factor that in. */
if (INTEGRAL_TYPE_P (TREE_TYPE (var)))
{
value_range nr;
value_range_kind rtype = get_range_info (var, nr);
if (rtype == VR_RANGE || rtype == VR_ANTI_RANGE)
value_range_equiv nr;
get_range_info (var, nr);
if (!nr.undefined_p ())
new_vr->intersect (&nr);
}
@ -258,7 +258,7 @@ vr_values::update_value_range (const_tree var, value_range *new_vr)
/* Return true if value range VR involves exactly one symbol SYM. */
static bool
symbolic_range_based_on_p (value_range_base *vr, const_tree sym)
symbolic_range_based_on_p (value_range *vr, const_tree sym)
{
bool neg, min_has_symbol, max_has_symbol;
tree inv;
@ -377,7 +377,8 @@ vr_values::vrp_stmt_computes_nonzero (gimple *stmt)
|| (flag_delete_null_pointer_checks
&& !TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr))))
{
const value_range *vr = get_value_range (TREE_OPERAND (base, 0));
const value_range_equiv *vr
= get_value_range (TREE_OPERAND (base, 0));
if (!range_includes_zero_p (vr))
return true;
}
@ -436,7 +437,7 @@ vr_values::op_with_constant_singleton_value_range (tree op)
bool
vr_values::op_with_boolean_value_range_p (tree op)
{
const value_range *vr;
const value_range_equiv *vr;
if (TYPE_PRECISION (TREE_TYPE (op)) == 1)
return true;
@ -461,10 +462,10 @@ void
vr_values::extract_range_for_var_from_comparison_expr (tree var,
enum tree_code cond_code,
tree op, tree limit,
value_range *vr_p)
value_range_equiv *vr_p)
{
tree min, max, type;
const value_range *limit_vr;
const value_range_equiv *limit_vr;
type = TREE_TYPE (var);
/* For pointer arithmetic, we only keep track of pointer equality
@ -538,7 +539,7 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var,
vice-versa. Use set_and_canonicalize which does this for
us. */
if (cond_code == LE_EXPR)
vr_p->set (VR_RANGE, min, max, vr_p->equiv ());
vr_p->set (VR_RANGE, min, max, vr_p->equiv ());
else if (cond_code == GT_EXPR)
vr_p->set (VR_ANTI_RANGE, min, max, vr_p->equiv ());
else
@ -705,7 +706,7 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var,
it in *VR_P. */
void
vr_values::extract_range_from_assert (value_range *vr_p, tree expr)
vr_values::extract_range_from_assert (value_range_equiv *vr_p, tree expr)
{
tree var = ASSERT_EXPR_VAR (expr);
tree cond = ASSERT_EXPR_COND (expr);
@ -751,9 +752,9 @@ vr_values::extract_range_from_assert (value_range *vr_p, tree expr)
always false. */
void
vr_values::extract_range_from_ssa_name (value_range *vr, tree var)
vr_values::extract_range_from_ssa_name (value_range_equiv *vr, tree var)
{
const value_range *var_vr = get_value_range (var);
const value_range_equiv *var_vr = get_value_range (var);
if (!var_vr->varying_p ())
vr->deep_copy (var_vr);
@ -769,13 +770,13 @@ vr_values::extract_range_from_ssa_name (value_range *vr, tree var)
The resulting range is stored in *VR. */
void
vr_values::extract_range_from_binary_expr (value_range *vr,
vr_values::extract_range_from_binary_expr (value_range_equiv *vr,
enum tree_code code,
tree expr_type, tree op0, tree op1)
{
/* Get value ranges for each operand. For constant operands, create
a new value range with the operand to simplify processing. */
value_range_base vr0, vr1;
value_range vr0, vr1;
if (TREE_CODE (op0) == SSA_NAME)
vr0 = *(get_value_range (op0));
else if (is_gimple_min_invariant (op0))
@ -796,13 +797,9 @@ vr_values::extract_range_from_binary_expr (value_range *vr,
&& TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (op0)))
{
if (vr0.varying_p () && !vr1.varying_p ())
vr0 = value_range (VR_RANGE,
vrp_val_min (expr_type),
vrp_val_max (expr_type));
vr0 = value_range (vrp_val_min (expr_type), vrp_val_max (expr_type));
else if (vr1.varying_p () && !vr0.varying_p ())
vr1 = value_range (VR_RANGE,
vrp_val_min (expr_type),
vrp_val_max (expr_type));
vr1 = value_range (vrp_val_min (expr_type), vrp_val_max (expr_type));
}
range_fold_binary_expr (vr, code, expr_type, &vr0, &vr1);
@ -917,10 +914,11 @@ vr_values::extract_range_from_binary_expr (value_range *vr,
The resulting range is stored in *VR. */
void
vr_values::extract_range_from_unary_expr (value_range *vr, enum tree_code code,
vr_values::extract_range_from_unary_expr (value_range_equiv *vr,
enum tree_code code,
tree type, tree op0)
{
value_range_base vr0;
value_range vr0;
/* Get value ranges for the operand. For constant operands, create
a new value range with the operand to simplify processing. */
@ -939,13 +937,13 @@ vr_values::extract_range_from_unary_expr (value_range *vr, enum tree_code code,
the ranges of each of its operands and the expression code. */
void
vr_values::extract_range_from_cond_expr (value_range *vr, gassign *stmt)
vr_values::extract_range_from_cond_expr (value_range_equiv *vr, gassign *stmt)
{
/* Get value ranges for each operand. For constant operands, create
a new value range with the operand to simplify processing. */
tree op0 = gimple_assign_rhs2 (stmt);
value_range tem0;
const value_range *vr0 = &tem0;
value_range_equiv tem0;
const value_range_equiv *vr0 = &tem0;
if (TREE_CODE (op0) == SSA_NAME)
vr0 = get_value_range (op0);
else if (is_gimple_min_invariant (op0))
@ -954,8 +952,8 @@ vr_values::extract_range_from_cond_expr (value_range *vr, gassign *stmt)
tem0.set_varying (TREE_TYPE (op0));
tree op1 = gimple_assign_rhs3 (stmt);
value_range tem1;
const value_range *vr1 = &tem1;
value_range_equiv tem1;
const value_range_equiv *vr1 = &tem1;
if (TREE_CODE (op1) == SSA_NAME)
vr1 = get_value_range (op1);
else if (is_gimple_min_invariant (op1))
@ -973,7 +971,8 @@ vr_values::extract_range_from_cond_expr (value_range *vr, gassign *stmt)
on the range of its operand and the expression code. */
void
vr_values::extract_range_from_comparison (value_range *vr, enum tree_code code,
vr_values::extract_range_from_comparison (value_range_equiv *vr,
enum tree_code code,
tree type, tree op0, tree op1)
{
bool sop;
@ -1007,7 +1006,7 @@ bool
vr_values::check_for_binary_op_overflow (enum tree_code subcode, tree type,
tree op0, tree op1, bool *ovf)
{
value_range_base vr0, vr1;
value_range vr0, vr1;
if (TREE_CODE (op0) == SSA_NAME)
vr0 = *get_value_range (op0);
else if (TREE_CODE (op0) == INTEGER_CST)
@ -1110,7 +1109,7 @@ vr_values::check_for_binary_op_overflow (enum tree_code subcode, tree type,
Store the result in *VR */
void
vr_values::extract_range_basic (value_range *vr, gimple *stmt)
vr_values::extract_range_basic (value_range_equiv *vr, gimple *stmt)
{
bool sop;
tree type = gimple_expr_type (stmt);
@ -1144,7 +1143,7 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
maxi = prec;
if (TREE_CODE (arg) == SSA_NAME)
{
const value_range *vr0 = get_value_range (arg);
const value_range_equiv *vr0 = get_value_range (arg);
/* If arg is non-zero, then ffs or popcount are non-zero. */
if (range_includes_zero_p (vr0) == 0)
mini = 1;
@ -1182,7 +1181,7 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
mini = -2;
if (TREE_CODE (arg) == SSA_NAME)
{
const value_range *vr0 = get_value_range (arg);
const value_range_equiv *vr0 = get_value_range (arg);
/* From clz of VR_RANGE minimum we can compute
result maximum. */
if (vr0->kind () == VR_RANGE
@ -1239,7 +1238,7 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
}
if (TREE_CODE (arg) == SSA_NAME)
{
const value_range *vr0 = get_value_range (arg);
const value_range_equiv *vr0 = get_value_range (arg);
/* If arg is non-zero, then use [0, prec - 1]. */
if ((vr0->kind () == VR_RANGE
&& integer_nonzerop (vr0->min ()))
@ -1420,7 +1419,7 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
}
else
{
value_range vr0, vr1;
value_range_equiv vr0, vr1;
bool saved_flag_wrapv = flag_wrapv;
/* Pretend the arithmetics is wrapping. If there is
any overflow, IMAGPART_EXPR will be set. */
@ -1454,7 +1453,7 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
in *VR. */
void
vr_values::extract_range_from_assignment (value_range *vr, gassign *stmt)
vr_values::extract_range_from_assignment (value_range_equiv *vr, gassign *stmt)
{
enum tree_code code = gimple_assign_rhs_code (stmt);
@ -1503,8 +1502,8 @@ vr_values::extract_range_from_assignment (value_range *vr, gassign *stmt)
static tree
compare_ranges (enum tree_code comp, const value_range *vr0,
const value_range *vr1, bool *strict_overflow_p)
compare_ranges (enum tree_code comp, const value_range_equiv *vr0,
const value_range_equiv *vr1, bool *strict_overflow_p)
{
/* VARYING or UNDEFINED ranges cannot be compared. */
if (vr0->varying_p ()
@ -1638,8 +1637,8 @@ compare_ranges (enum tree_code comp, const value_range *vr0,
assumed signed overflow is undefined. */
static tree
compare_range_with_value (enum tree_code comp, const value_range *vr, tree val,
bool *strict_overflow_p)
compare_range_with_value (enum tree_code comp, const value_range_equiv *vr,
tree val, bool *strict_overflow_p)
{
if (vr->varying_p () || vr->undefined_p ())
return NULL_TREE;
@ -1742,7 +1741,7 @@ compare_range_with_value (enum tree_code comp, const value_range *vr, tree val,
for VAR. If so, update VR with the new limits. */
void
vr_values::adjust_range_with_scev (value_range *vr, class loop *loop,
vr_values::adjust_range_with_scev (value_range_equiv *vr, class loop *loop,
gimple *stmt, tree var)
{
tree init, step, chrec, tmin, tmax, min, max, type, tem;
@ -1815,7 +1814,6 @@ vr_values::adjust_range_with_scev (value_range *vr, class loop *loop,
the number of latch executions is the correct thing to use. */
if (max_loop_iterations (loop, &nit))
{
value_range maxvr;
signop sgn = TYPE_SIGN (TREE_TYPE (step));
wi::overflow_type overflow;
@ -1831,13 +1829,14 @@ vr_values::adjust_range_with_scev (value_range *vr, class loop *loop,
&& (sgn == UNSIGNED
|| wi::gts_p (wtmp, 0) == wi::gts_p (wi::to_wide (step), 0)))
{
value_range_equiv maxvr;
tem = wide_int_to_tree (TREE_TYPE (init), wtmp);
extract_range_from_binary_expr (&maxvr, PLUS_EXPR,
TREE_TYPE (init), init, tem);
/* Likewise if the addition did. */
if (maxvr.kind () == VR_RANGE)
{
value_range_base initvr;
value_range initvr;
if (TREE_CODE (init) == SSA_NAME)
initvr = *(get_value_range (init));
@ -1952,7 +1951,7 @@ vr_values::vr_values () : vrp_value_range_pool ("Tree VRP value ranges")
{
values_propagated = false;
num_vr_values = num_ssa_names * 2;
vr_value = XCNEWVEC (value_range *, num_vr_values);
vr_value = XCNEWVEC (value_range_equiv *, num_vr_values);
vr_phi_edge_counts = XCNEWVEC (int, num_ssa_names);
bitmap_obstack_initialize (&vrp_equiv_obstack);
to_remove_edges = vNULL;
@ -1992,7 +1991,7 @@ vrp_valueize (tree name)
{
if (TREE_CODE (name) == SSA_NAME)
{
const value_range *vr = x_vr_values->get_value_range (name);
const value_range_equiv *vr = x_vr_values->get_value_range (name);
if (vr->kind () == VR_RANGE
&& (TREE_CODE (vr->min ()) == SSA_NAME
|| is_gimple_min_invariant (vr->min ()))
@ -2017,7 +2016,7 @@ vrp_valueize_1 (tree name)
if (!gimple_nop_p (def_stmt)
&& prop_simulate_again_p (def_stmt))
return NULL_TREE;
const value_range *vr = x_vr_values->get_value_range (name);
const value_range_equiv *vr = x_vr_values->get_value_range (name);
tree singleton;
if (vr->singleton_p (&singleton))
return singleton;
@ -2053,7 +2052,7 @@ get_output_for_vrp (gimple *stmt)
void
vr_values::vrp_visit_assignment_or_call (gimple *stmt, tree *output_p,
value_range *vr)
value_range_equiv *vr)
{
tree lhs = get_output_for_vrp (stmt);
*output_p = lhs;
@ -2095,11 +2094,11 @@ vr_values::vrp_visit_assignment_or_call (gimple *stmt, tree *output_p,
or a symbolic range containing the SSA_NAME only if the value range
is varying or undefined. Uses TEM as storage for the alternate range. */
const value_range *
vr_values::get_vr_for_comparison (int i, value_range *tem)
const value_range_equiv *
vr_values::get_vr_for_comparison (int i, value_range_equiv *tem)
{
/* Shallow-copy equiv bitmap. */
const value_range *vr = get_value_range (ssa_name (i));
const value_range_equiv *vr = get_value_range (ssa_name (i));
/* If name N_i does not have a valid range, use N_i as its own
range. This allows us to compare against names that may
@ -2122,52 +2121,46 @@ tree
vr_values::compare_name_with_value (enum tree_code comp, tree var, tree val,
bool *strict_overflow_p, bool use_equiv_p)
{
bitmap_iterator bi;
unsigned i;
bitmap e;
tree retval, t;
int used_strict_overflow;
bool sop;
const value_range *equiv_vr;
value_range tem_vr;
/* Get the set of equivalences for VAR. */
e = get_value_range (var)->equiv ();
bitmap e = get_value_range (var)->equiv ();
/* Start at -1. Set it to 0 if we do a comparison without relying
on overflow, or 1 if all comparisons rely on overflow. */
used_strict_overflow = -1;
int used_strict_overflow = -1;
/* Compare vars' value range with val. */
equiv_vr = get_vr_for_comparison (SSA_NAME_VERSION (var), &tem_vr);
sop = false;
retval = compare_range_with_value (comp, equiv_vr, val, &sop);
value_range_equiv tem_vr;
const value_range_equiv *equiv_vr
= get_vr_for_comparison (SSA_NAME_VERSION (var), &tem_vr);
bool sop = false;
tree retval = compare_range_with_value (comp, equiv_vr, val, &sop);
if (retval)
used_strict_overflow = sop ? 1 : 0;
/* If the equiv set is empty we have done all work we need to do. */
if (e == NULL)
{
if (retval
&& used_strict_overflow > 0)
if (retval && used_strict_overflow > 0)
*strict_overflow_p = true;
return retval;
}
unsigned i;
bitmap_iterator bi;
EXECUTE_IF_SET_IN_BITMAP (e, 0, i, bi)
{
tree name = ssa_name (i);
if (! name)
if (!name)
continue;
if (! use_equiv_p
&& ! SSA_NAME_IS_DEFAULT_DEF (name)
if (!use_equiv_p
&& !SSA_NAME_IS_DEFAULT_DEF (name)
&& prop_simulate_again_p (SSA_NAME_DEF_STMT (name)))
continue;
equiv_vr = get_vr_for_comparison (i, &tem_vr);
sop = false;
t = compare_range_with_value (comp, equiv_vr, val, &sop);
tree t = compare_range_with_value (comp, equiv_vr, val, &sop);
if (t)
{
/* If we get different answers from different members
@ -2189,8 +2182,7 @@ vr_values::compare_name_with_value (enum tree_code comp, tree var, tree val,
}
}
if (retval
&& used_strict_overflow > 0)
if (retval && used_strict_overflow > 0)
*strict_overflow_p = true;
return retval;
@ -2208,20 +2200,14 @@ tree
vr_values::compare_names (enum tree_code comp, tree n1, tree n2,
bool *strict_overflow_p)
{
tree t, retval;
bitmap e1, e2;
bitmap_iterator bi1, bi2;
unsigned i1, i2;
int used_strict_overflow;
static bitmap_obstack *s_obstack = NULL;
static bitmap s_e1 = NULL, s_e2 = NULL;
/* Compare the ranges of every name equivalent to N1 against the
ranges of every name equivalent to N2. */
e1 = get_value_range (n1)->equiv ();
e2 = get_value_range (n2)->equiv ();
bitmap e1 = get_value_range (n1)->equiv ();
bitmap e2 = get_value_range (n2)->equiv ();
/* Use the fake bitmaps if e1 or e2 are not available. */
static bitmap s_e1 = NULL, s_e2 = NULL;
static bitmap_obstack *s_obstack = NULL;
if (s_obstack == NULL)
{
s_obstack = XNEW (bitmap_obstack);
@ -2254,29 +2240,33 @@ vr_values::compare_names (enum tree_code comp, tree n1, tree n2,
/* Start at -1. Set it to 0 if we do a comparison without relying
on overflow, or 1 if all comparisons rely on overflow. */
used_strict_overflow = -1;
int used_strict_overflow = -1;
/* Otherwise, compare all the equivalent ranges. First, add N1 and
N2 to their own set of equivalences to avoid duplicating the body
of the loop just to check N1 and N2 ranges. */
bitmap_iterator bi1;
unsigned i1;
EXECUTE_IF_SET_IN_BITMAP (e1, 0, i1, bi1)
{
if (! ssa_name (i1))
if (!ssa_name (i1))
continue;
value_range tem_vr1;
const value_range *vr1 = get_vr_for_comparison (i1, &tem_vr1);
value_range_equiv tem_vr1;
const value_range_equiv *vr1 = get_vr_for_comparison (i1, &tem_vr1);
t = retval = NULL_TREE;
tree t = NULL_TREE, retval = NULL_TREE;
bitmap_iterator bi2;
unsigned i2;
EXECUTE_IF_SET_IN_BITMAP (e2, 0, i2, bi2)
{
if (! ssa_name (i2))
if (!ssa_name (i2))
continue;
bool sop = false;
value_range tem_vr2;
const value_range *vr2 = get_vr_for_comparison (i2, &tem_vr2);
value_range_equiv tem_vr2;
const value_range_equiv *vr2 = get_vr_for_comparison (i2, &tem_vr2);
t = compare_ranges (comp, vr1, vr2, &sop);
if (t)
@ -2285,8 +2275,7 @@ vr_values::compare_names (enum tree_code comp, tree n1, tree n2,
of the equivalence set this check must be in a dead
code region. Folding it to a trap representation
would be correct here. For now just return don't-know. */
if (retval != NULL
&& t != retval)
if (retval != NULL && t != retval)
{
bitmap_clear_bit (e1, SSA_NAME_VERSION (n1));
bitmap_clear_bit (e2, SSA_NAME_VERSION (n2));
@ -2325,8 +2314,7 @@ tree
vr_values::vrp_evaluate_conditional_warnv_with_ops_using_ranges
(enum tree_code code, tree op0, tree op1, bool * strict_overflow_p)
{
const value_range *vr0, *vr1;
const value_range_equiv *vr0, *vr1;
vr0 = (TREE_CODE (op0) == SSA_NAME) ? get_value_range (op0) : NULL;
vr1 = (TREE_CODE (op1) == SSA_NAME) ? get_value_range (op1) : NULL;
@ -2392,7 +2380,7 @@ vr_values::vrp_evaluate_conditional_warnv_with_ops (enum tree_code code,
}
else
{
value_range_base vro, vri;
value_range vro, vri;
if (code == GT_EXPR || code == GE_EXPR)
{
vro.set (VR_ANTI_RANGE, TYPE_MIN_VALUE (TREE_TYPE (op0)), x);
@ -2405,7 +2393,7 @@ vr_values::vrp_evaluate_conditional_warnv_with_ops (enum tree_code code,
}
else
gcc_unreachable ();
const value_range *vr0 = get_value_range (op0);
const value_range_equiv *vr0 = get_value_range (op0);
/* If vro, the range for OP0 to pass the overflow test, has
no intersection with *vr0, OP0's known range, then the
overflow test can't pass, so return the node for false.
@ -2511,7 +2499,7 @@ vr_values::vrp_evaluate_conditional (tree_code code, tree op0,
always fold regardless of the value of OP0. If -Wtype-limits
was specified, emit a warning. */
tree type = TREE_TYPE (op0);
const value_range *vr0 = get_value_range (op0);
const value_range_equiv *vr0 = get_value_range (op0);
if (vr0->kind () == VR_RANGE
&& INTEGRAL_TYPE_P (type)
@ -2637,9 +2625,9 @@ vr_values::vrp_visit_cond_stmt (gcond *stmt, edge *taken_edge_p)
Returns true if the default label is not needed. */
static bool
find_case_label_ranges (gswitch *stmt, const value_range *vr, size_t *min_idx1,
size_t *max_idx1, size_t *min_idx2,
size_t *max_idx2)
find_case_label_ranges (gswitch *stmt, const value_range_equiv *vr,
size_t *min_idx1, size_t *max_idx1,
size_t *min_idx2, size_t *max_idx2)
{
size_t i, j, k, l;
unsigned int n = gimple_switch_num_labels (stmt);
@ -2717,7 +2705,7 @@ void
vr_values::vrp_visit_switch_stmt (gswitch *stmt, edge *taken_edge_p)
{
tree op, val;
const value_range *vr;
const value_range_equiv *vr;
size_t i = 0, j = 0, k, l;
bool take_default;
@ -2807,7 +2795,7 @@ vr_values::vrp_visit_switch_stmt (gswitch *stmt, edge *taken_edge_p)
void
vr_values::extract_range_from_stmt (gimple *stmt, edge *taken_edge_p,
tree *output_p, value_range *vr)
tree *output_p, value_range_equiv *vr)
{
if (dump_file && (dump_flags & TDF_DETAILS))
@ -2831,13 +2819,13 @@ vr_values::extract_range_from_stmt (gimple *stmt, edge *taken_edge_p,
value ranges, set a new range in VR_RESULT. */
void
vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
vr_values::extract_range_from_phi_node (gphi *phi,
value_range_equiv *vr_result)
{
size_t i;
tree lhs = PHI_RESULT (phi);
const value_range *lhs_vr = get_value_range (lhs);
const value_range_equiv *lhs_vr = get_value_range (lhs);
bool first = true;
int edges, old_edges;
int old_edges;
class loop *l;
if (dump_file && (dump_flags & TDF_DETAILS))
@ -2847,8 +2835,8 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
}
bool may_simulate_backedge_again = false;
edges = 0;
for (i = 0; i < gimple_phi_num_args (phi); i++)
int edges = 0;
for (size_t i = 0; i < gimple_phi_num_args (phi); i++)
{
edge e = gimple_phi_arg_edge (phi, i);
@ -2862,12 +2850,12 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
if (e->flags & EDGE_EXECUTABLE)
{
tree arg = PHI_ARG_DEF (phi, i);
value_range vr_arg_tem;
const value_range *vr_arg = &vr_arg_tem;
value_range_equiv vr_arg_tem;
const value_range_equiv *vr_arg = &vr_arg_tem;
++edges;
tree arg = PHI_ARG_DEF (phi, i);
if (TREE_CODE (arg) == SSA_NAME)
{
/* See if we are eventually going to change one of the args. */
@ -2877,7 +2865,7 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
&& e->flags & EDGE_DFS_BACK)
may_simulate_backedge_again = true;
const value_range *vr_arg_ = get_value_range (arg);
const value_range_equiv *vr_arg_ = get_value_range (arg);
/* Do not allow equivalences or symbolic ranges to leak in from
backedges. That creates invalid equivalencies.
See PR53465 and PR54767. */
@ -3128,7 +3116,7 @@ vr_values::simplify_div_or_mod_using_ranges (gimple_stmt_iterator *gsi,
tree op1 = gimple_assign_rhs2 (stmt);
tree op0min = NULL_TREE, op0max = NULL_TREE;
tree op1min = op1;
const value_range *vr = NULL;
const value_range_equiv *vr = NULL;
if (TREE_CODE (op0) == INTEGER_CST)
{
@ -3148,7 +3136,7 @@ vr_values::simplify_div_or_mod_using_ranges (gimple_stmt_iterator *gsi,
if (rhs_code == TRUNC_MOD_EXPR
&& TREE_CODE (op1) == SSA_NAME)
{
const value_range *vr1 = get_value_range (op1);
const value_range_equiv *vr1 = get_value_range (op1);
if (range_int_cst_p (vr1))
op1min = vr1->min ();
}
@ -3295,7 +3283,7 @@ bool
vr_values::simplify_abs_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
{
tree op = gimple_assign_rhs1 (stmt);
const value_range *vr = get_value_range (op);
const value_range_equiv *vr = get_value_range (op);
if (vr)
{
@ -3348,7 +3336,7 @@ vr_values::simplify_abs_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
static bool
vr_set_zero_nonzero_bits (const tree expr_type,
const value_range_base *vr,
const value_range *vr,
wide_int *may_be_nonzero,
wide_int *must_be_nonzero)
{
@ -3378,7 +3366,7 @@ vr_values::simplify_bit_ops_using_ranges (gimple_stmt_iterator *gsi,
tree op0 = gimple_assign_rhs1 (stmt);
tree op1 = gimple_assign_rhs2 (stmt);
tree op = NULL_TREE;
value_range_base vr0, vr1;
value_range vr0, vr1;
wide_int may_be_nonzero0, may_be_nonzero1;
wide_int must_be_nonzero0, must_be_nonzero1;
wide_int mask;
@ -3457,7 +3445,7 @@ vr_values::simplify_bit_ops_using_ranges (gimple_stmt_iterator *gsi,
static tree
test_for_singularity (enum tree_code cond_code, tree op0,
tree op1, const value_range *vr)
tree op1, const value_range_equiv *vr)
{
tree min = NULL;
tree max = NULL;
@ -3515,7 +3503,7 @@ test_for_singularity (enum tree_code cond_code, tree op0,
by PRECISION and UNSIGNED_P. */
static bool
range_fits_type_p (const value_range *vr,
range_fits_type_p (const value_range_equiv *vr,
unsigned dest_precision, signop dest_sgn)
{
tree src_type;
@ -3580,7 +3568,7 @@ vr_values::simplify_cond_using_ranges_1 (gcond *stmt)
&& INTEGRAL_TYPE_P (TREE_TYPE (op0))
&& is_gimple_min_invariant (op1))
{
const value_range *vr = get_value_range (op0);
const value_range_equiv *vr = get_value_range (op0);
/* If we have range information for OP0, then we might be
able to simplify this conditional. */
@ -3683,7 +3671,7 @@ vr_values::simplify_cond_using_ranges_2 (gcond *stmt)
&& !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (innerop)
&& desired_pro_or_demotion_p (TREE_TYPE (innerop), TREE_TYPE (op0)))
{
const value_range *vr = get_value_range (innerop);
const value_range_equiv *vr = get_value_range (innerop);
if (range_int_cst_p (vr)
&& range_fits_type_p (vr,
@ -3713,7 +3701,7 @@ bool
vr_values::simplify_switch_using_ranges (gswitch *stmt)
{
tree op = gimple_switch_index (stmt);
const value_range *vr = NULL;
const value_range_equiv *vr = NULL;
bool take_default;
edge e;
edge_iterator ei;
@ -4013,7 +4001,7 @@ vr_values::simplify_float_conversion_using_ranges (gimple_stmt_iterator *gsi,
gimple *stmt)
{
tree rhs1 = gimple_assign_rhs1 (stmt);
const value_range *vr = get_value_range (rhs1);
const value_range_equiv *vr = get_value_range (rhs1);
scalar_float_mode fltmode
= SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt)));
scalar_int_mode mode;
@ -4176,7 +4164,7 @@ vr_values::simplify_internal_call_using_ranges (gimple_stmt_iterator *gsi,
bool
vr_values::two_valued_val_range_p (tree var, tree *a, tree *b)
{
const value_range *vr = get_value_range (var);
const value_range_equiv *vr = get_value_range (var);
if (vr->varying_p ()
|| vr->undefined_p ()
|| TREE_CODE (vr->min ()) != INTEGER_CST
@ -4355,7 +4343,7 @@ vr_values::simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
/* Set the lattice entry for VAR to VR. */
void
vr_values::set_vr_value (tree var, value_range *vr)
vr_values::set_vr_value (tree var, value_range_equiv *vr)
{
if (SSA_NAME_VERSION (var) >= num_vr_values)
return;
@ -4364,8 +4352,8 @@ vr_values::set_vr_value (tree var, value_range *vr)
/* Swap the lattice entry for VAR with VR and return the old entry. */
value_range *
vr_values::swap_vr_value (tree var, value_range *vr)
value_range_equiv *
vr_values::swap_vr_value (tree var, value_range_equiv *vr)
{
if (SSA_NAME_VERSION (var) >= num_vr_values)
return NULL;

View file

@ -40,23 +40,25 @@ class vr_values
vr_values (void);
~vr_values (void);
const value_range *get_value_range (const_tree);
void set_vr_value (tree, value_range *);
value_range *swap_vr_value (tree, value_range *);
const value_range_equiv *get_value_range (const_tree);
void set_vr_value (tree, value_range_equiv *);
value_range_equiv *swap_vr_value (tree, value_range_equiv *);
void set_def_to_varying (const_tree);
void set_defs_to_varying (gimple *);
bool update_value_range (const_tree, value_range *);
bool update_value_range (const_tree, value_range_equiv *);
tree op_with_constant_singleton_value_range (tree);
void adjust_range_with_scev (value_range *, class loop *, gimple *, tree);
void adjust_range_with_scev (value_range_equiv *, class loop *,
gimple *, tree);
tree vrp_evaluate_conditional (tree_code, tree, tree, gimple *);
void dump_all_value_ranges (FILE *);
void extract_range_for_var_from_comparison_expr (tree, enum tree_code,
tree, tree, value_range *);
void extract_range_from_phi_node (gphi *, value_range *);
void extract_range_basic (value_range *, gimple *);
void extract_range_from_stmt (gimple *, edge *, tree *, value_range *);
tree, tree,
value_range_equiv *);
void extract_range_from_phi_node (gphi *, value_range_equiv *);
void extract_range_basic (value_range_equiv *, gimple *);
void extract_range_from_stmt (gimple *, edge *, tree *, value_range_equiv *);
void vrp_visit_cond_stmt (gcond *, edge *);
@ -67,20 +69,20 @@ class vr_values
void set_lattice_propagation_complete (void) { values_propagated = true; }
/* Allocate a new value_range object. */
value_range *allocate_value_range (void)
value_range_equiv *allocate_value_range_equiv (void)
{ return vrp_value_range_pool.allocate (); }
void free_value_range (value_range *vr)
void free_value_range (value_range_equiv *vr)
{ vrp_value_range_pool.remove (vr); }
/* */
void cleanup_edges_and_switches (void);
private:
value_range *get_lattice_entry (const_tree);
value_range_equiv *get_lattice_entry (const_tree);
bool vrp_stmt_computes_nonzero (gimple *);
bool op_with_boolean_value_range_p (tree);
bool check_for_binary_op_overflow (enum tree_code, tree, tree, tree, bool *);
const value_range *get_vr_for_comparison (int, value_range *);
const value_range_equiv *get_vr_for_comparison (int, value_range_equiv *);
tree compare_name_with_value (enum tree_code, tree, tree, bool *, bool);
tree compare_names (enum tree_code, tree, tree, bool *);
bool two_valued_val_range_p (tree, tree *, tree *);
@ -90,17 +92,17 @@ class vr_values
tree vrp_evaluate_conditional_warnv_with_ops (enum tree_code,
tree, tree, bool,
bool *, bool *);
void extract_range_from_assignment (value_range *, gassign *);
void extract_range_from_assert (value_range *, tree);
void extract_range_from_ssa_name (value_range *, tree);
void extract_range_from_binary_expr (value_range *, enum tree_code,
void extract_range_from_assignment (value_range_equiv *, gassign *);
void extract_range_from_assert (value_range_equiv *, tree);
void extract_range_from_ssa_name (value_range_equiv *, tree);
void extract_range_from_binary_expr (value_range_equiv *, enum tree_code,
tree, tree, tree);
void extract_range_from_unary_expr (value_range *, enum tree_code,
void extract_range_from_unary_expr (value_range_equiv *, enum tree_code,
tree, tree);
void extract_range_from_cond_expr (value_range *, gassign *);
void extract_range_from_comparison (value_range *, enum tree_code,
void extract_range_from_cond_expr (value_range_equiv *, gassign *);
void extract_range_from_comparison (value_range_equiv *, enum tree_code,
tree, tree, tree);
void vrp_visit_assignment_or_call (gimple*, tree *, value_range *);
void vrp_visit_assignment_or_call (gimple*, tree *, value_range_equiv *);
void vrp_visit_switch_stmt (gswitch *, edge *);
bool simplify_truth_ops_using_ranges (gimple_stmt_iterator *, gimple *);
bool simplify_div_or_mod_using_ranges (gimple_stmt_iterator *, gimple *);
@ -114,7 +116,7 @@ class vr_values
bool simplify_internal_call_using_ranges (gimple_stmt_iterator *, gimple *);
/* Allocation pools for value_range objects. */
object_allocator<value_range> vrp_value_range_pool;
object_allocator<value_range_equiv> vrp_value_range_pool;
/* This probably belongs in the lattice rather than in here. */
bool values_propagated;
@ -125,7 +127,7 @@ class vr_values
/* Value range array. After propagation, VR_VALUE[I] holds the range
of values that SSA name N_I may take. */
unsigned int num_vr_values;
value_range **vr_value;
value_range_equiv **vr_value;
/* For a PHI node which sets SSA name N_I, VR_COUNTS[I] holds the
number of executable edges we saw the last time we visited the