aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/gimple-fold.c8
-rw-r--r--gcc/gimple-loop-versioning.cc2
-rw-r--r--gcc/gimple-ssa-evrp-analyze.c60
-rw-r--r--gcc/gimple-ssa-evrp-analyze.h11
-rw-r--r--gcc/gimple-ssa-evrp.c9
-rw-r--r--gcc/gimple-ssa-sprintf.c6
-rw-r--r--gcc/ipa-cp.c22
-rw-r--r--gcc/ipa-prop.c40
-rw-r--r--gcc/ipa-prop.h2
-rw-r--r--gcc/range-op.cc1278
-rw-r--r--gcc/range-op.h22
-rw-r--r--gcc/range.cc37
-rw-r--r--gcc/range.h16
-rw-r--r--gcc/selftest.h2
-rw-r--r--gcc/tree-ssa-dom.c6
-rw-r--r--gcc/tree-ssa-strlen.c10
-rw-r--r--gcc/tree-ssa-threadedge.c4
-rw-r--r--gcc/tree-ssanames.c4
-rw-r--r--gcc/tree-ssanames.h4
-rw-r--r--gcc/tree-vrp.c301
-rw-r--r--gcc/tree-vrp.h130
-rw-r--r--gcc/vr-values.c260
-rw-r--r--gcc/vr-values.h48
24 files changed, 1140 insertions, 1152 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2bb973f..d5e0f61 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index dc3d228..1dfb238 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -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 ();
diff --git a/gcc/gimple-loop-versioning.cc b/gcc/gimple-loop-versioning.cc
index 35344b7..1664d87 100644
--- a/gcc/gimple-loop-versioning.cc
+++ b/gcc/gimple-loop-versioning.cc
@@ -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 ())
diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c
index 68f317f..3a9fa75 100644
--- a/gcc/gimple-ssa-evrp-analyze.c
+++ b/gcc/gimple-ssa-evrp-analyze.c
@@ -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);
}
diff --git a/gcc/gimple-ssa-evrp-analyze.h b/gcc/gimple-ssa-evrp-analyze.h
index a136cea..f6512a3 100644
--- a/gcc/gimple-ssa-evrp-analyze.h
+++ b/gcc/gimple-ssa-evrp-analyze.h
@@ -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;
diff --git a/gcc/gimple-ssa-evrp.c b/gcc/gimple-ssa-evrp.c
index c4ac137..a704cd5 100644
--- a/gcc/gimple-ssa-evrp.c
+++ b/gcc/gimple-ssa-evrp.c
@@ -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);
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index b548bbd..ef04b2a 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -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))
diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 8a5f8d3..c6bd265 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -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,
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 3a6e21b..094e681 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -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,
diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h
index 9f2479e..7a9e4bc 100644
--- a/gcc/ipa-prop.h
+++ b/gcc/ipa-prop.h
@@ -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
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 56e8a20..8ec8392 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -66,9 +66,8 @@ min_limit (const_tree type)
// undefined and return TRUE.
inline bool
-empty_range_check (value_range_base &r,
- const value_range_base &op1,
- const value_range_base & op2)
+empty_range_check (value_range &r,
+ const value_range &op1, const value_range & op2)
{
if (op1.undefined_p () || op2.undefined_p ())
{
@@ -83,12 +82,11 @@ empty_range_check (value_range_base &r,
// the appropriate range.
static inline bool
-undefined_shift_range_check (value_range_base &r, tree type,
- value_range_base op)
+undefined_shift_range_check (value_range &r, tree type, const value_range op)
{
if (op.undefined_p ())
{
- r = value_range_base ();
+ r = value_range ();
return true;
}
@@ -100,7 +98,7 @@ undefined_shift_range_check (value_range_base &r, tree type,
|| wi::ge_p (op.upper_bound (),
TYPE_PRECISION (type), TYPE_SIGN (op.type ())))
{
- r = value_range_base (type);
+ r = value_range (type);
return true;
}
return false;
@@ -126,25 +124,25 @@ wi_zero_p (tree type, const wide_int &wmin, const wide_int &wmax)
// Default wide_int fold operation returns [MIN, MAX].
-value_range_base
+value_range
range_operator::wi_fold (tree type,
const wide_int &lh_lb ATTRIBUTE_UNUSED,
const wide_int &lh_ub ATTRIBUTE_UNUSED,
const wide_int &rh_lb ATTRIBUTE_UNUSED,
const wide_int &rh_ub ATTRIBUTE_UNUSED) const
{
- return value_range_base (type);
+ return value_range (type);
}
// The default for fold is to break all ranges into sub-ranges and
// invoke the wi_fold method on each sub-range pair.
-value_range_base
+value_range
range_operator::fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const
+ const value_range &lh,
+ const value_range &rh) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, lh, rh))
return r;
@@ -165,10 +163,10 @@ range_operator::fold_range (tree type,
// The default for op1_range is to return false.
bool
-range_operator::op1_range (value_range_base &r ATTRIBUTE_UNUSED,
+range_operator::op1_range (value_range &r ATTRIBUTE_UNUSED,
tree type ATTRIBUTE_UNUSED,
- const value_range_base &lhs ATTRIBUTE_UNUSED,
- const value_range_base &op2 ATTRIBUTE_UNUSED) const
+ const value_range &lhs ATTRIBUTE_UNUSED,
+ const value_range &op2 ATTRIBUTE_UNUSED) const
{
return false;
}
@@ -176,10 +174,10 @@ range_operator::op1_range (value_range_base &r ATTRIBUTE_UNUSED,
// The default for op2_range is to return false.
bool
-range_operator::op2_range (value_range_base &r ATTRIBUTE_UNUSED,
+range_operator::op2_range (value_range &r ATTRIBUTE_UNUSED,
tree type ATTRIBUTE_UNUSED,
- const value_range_base &lhs ATTRIBUTE_UNUSED,
- const value_range_base &op1 ATTRIBUTE_UNUSED) const
+ const value_range &lhs ATTRIBUTE_UNUSED,
+ const value_range &op1 ATTRIBUTE_UNUSED) const
{
return false;
}
@@ -188,7 +186,7 @@ range_operator::op2_range (value_range_base &r ATTRIBUTE_UNUSED,
// Create and return a range from a pair of wide-ints that are known
// to have overflowed (or underflowed).
-static value_range_base
+static value_range
value_range_from_overflowed_bounds (tree type,
const wide_int &wmin,
const wide_int &wmax)
@@ -212,16 +210,16 @@ value_range_from_overflowed_bounds (tree type,
// Likewise if the anti-range bounds are outside of the types
// values.
if (covers || wi::cmp (tmin, tmax, sgn) > 0)
- return value_range_base (type);
+ return value_range (type);
- return value_range_base (VR_ANTI_RANGE, type, tmin, tmax);
+ return value_range (VR_ANTI_RANGE, type, tmin, tmax);
}
// Create and return a range from a pair of wide-ints. MIN_OVF and
// MAX_OVF describe any overflow that might have occurred while
// calculating WMIN and WMAX respectively.
-static value_range_base
+static value_range
value_range_with_overflow (tree type,
const wide_int &wmin, const wide_int &wmax,
wi::overflow_type min_ovf = wi::OVF_NONE,
@@ -234,7 +232,7 @@ value_range_with_overflow (tree type,
// For one bit precision if max != min, then the range covers all
// values.
if (prec == 1 && wi::ne_p (wmax, wmin))
- return value_range_base (type);
+ return value_range (type);
if (overflow_wraps)
{
@@ -247,11 +245,11 @@ value_range_with_overflow (tree type,
// If the limits are swapped, we wrapped around and cover
// the entire range.
if (wi::gt_p (tmin, tmax, sgn))
- return value_range_base (type);
+ return value_range (type);
// No overflow or both overflow or underflow. The range
// kind stays normal.
- return value_range_base (type, tmin, tmax);
+ return value_range (type, tmin, tmax);
}
if ((min_ovf == wi::OVF_UNDERFLOW && max_ovf == wi::OVF_NONE)
@@ -259,7 +257,7 @@ value_range_with_overflow (tree type,
return value_range_from_overflowed_bounds (type, wmin, wmax);
// Other underflow and/or overflow, drop to VR_VARYING.
- return value_range_base (type);
+ return value_range (type);
}
else
{
@@ -279,7 +277,7 @@ value_range_with_overflow (tree type,
else
new_ub = wmax;
- return value_range_base (type, new_lb, new_ub);
+ return value_range (type, new_lb, new_ub);
}
}
@@ -287,7 +285,7 @@ value_range_with_overflow (tree type,
// the case where the bounds are swapped. In which case, we transform
// [10,5] into [MIN,5][10,MAX].
-static inline value_range_base
+static inline value_range
create_possibly_reversed_range (tree type,
const wide_int &new_lb, const wide_int &new_ub)
{
@@ -297,34 +295,34 @@ create_possibly_reversed_range (tree type,
return value_range_from_overflowed_bounds (type, new_lb, new_ub);
// Otherwise its just a normal range.
- return value_range_base (type, new_lb, new_ub);
+ return value_range (type, new_lb, new_ub);
}
-// Return a value_range_base instance that is a boolean TRUE.
+// Return a value_range instance that is a boolean TRUE.
-static inline value_range_base
+static inline value_range
range_true (tree type)
{
unsigned prec = TYPE_PRECISION (type);
- return value_range_base (type, wi::one (prec), wi::one (prec));
+ return value_range (type, wi::one (prec), wi::one (prec));
}
-// Return a value_range_base instance that is a boolean FALSE.
+// Return a value_range instance that is a boolean FALSE.
-static inline value_range_base
+static inline value_range
range_false (tree type)
{
unsigned prec = TYPE_PRECISION (type);
- return value_range_base (type, wi::zero (prec), wi::zero (prec));
+ return value_range (type, wi::zero (prec), wi::zero (prec));
}
-// Return a value_range_base that covers both true and false.
+// Return a value_range that covers both true and false.
-static inline value_range_base
+static inline value_range
range_true_and_false (tree type)
{
unsigned prec = TYPE_PRECISION (type);
- return value_range_base (type, wi::zero (prec), wi::one (prec));
+ return value_range (type, wi::zero (prec), wi::one (prec));
}
enum bool_range_state { BRS_FALSE, BRS_TRUE, BRS_EMPTY, BRS_FULL };
@@ -335,8 +333,7 @@ enum bool_range_state { BRS_FALSE, BRS_TRUE, BRS_EMPTY, BRS_FULL };
// the bool range.
static bool_range_state
-get_bool_state (value_range_base &r,
- const value_range_base &lhs, tree val_type)
+get_bool_state (value_range &r, const value_range &lhs, tree val_type)
{
// If there is no result, then this is unexecutable.
if (lhs.undefined_p ())
@@ -362,23 +359,23 @@ get_bool_state (value_range_base &r,
class operator_equal : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &val) const;
- virtual bool op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &val) const;
+ virtual value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &val) const;
+ virtual bool op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &val) const;
} op_equal;
-value_range_base
+value_range
operator_equal::fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const
+ const value_range &op1,
+ const value_range &op2) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, op1, op2))
return r;
@@ -407,9 +404,9 @@ operator_equal::fold_range (tree type,
}
bool
-operator_equal::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_equal::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -434,9 +431,9 @@ operator_equal::op1_range (value_range_base &r, tree type,
}
bool
-operator_equal::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_equal::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
return operator_equal::op1_range (r, type, lhs, op1);
}
@@ -445,23 +442,23 @@ operator_equal::op2_range (value_range_base &r, tree type,
class operator_not_equal : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- 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 value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) 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;
} op_not_equal;
-value_range_base
+value_range
operator_not_equal::fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const
+ const value_range &op1,
+ const value_range &op2) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, op1, op2))
return r;
@@ -490,9 +487,9 @@ operator_not_equal::fold_range (tree type,
}
bool
-operator_not_equal::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_not_equal::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -518,9 +515,9 @@ operator_not_equal::op1_range (value_range_base &r, tree type,
bool
-operator_not_equal::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_not_equal::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
return operator_not_equal::op1_range (r, type, lhs, op1);
}
@@ -528,7 +525,7 @@ operator_not_equal::op2_range (value_range_base &r, tree type,
// (X < VAL) produces the range of [MIN, VAL - 1].
static void
-build_lt (value_range_base &r, tree type, const wide_int &val)
+build_lt (value_range &r, tree type, const wide_int &val)
{
wi::overflow_type ov;
wide_int lim = wi::sub (val, 1, TYPE_SIGN (type), &ov);
@@ -537,21 +534,21 @@ build_lt (value_range_base &r, tree type, const wide_int &val)
if (ov)
r.set_undefined ();
else
- r = value_range_base (type, min_limit (type), lim);
+ r = value_range (type, min_limit (type), lim);
}
// (X <= VAL) produces the range of [MIN, VAL].
static void
-build_le (value_range_base &r, tree type, const wide_int &val)
+build_le (value_range &r, tree type, const wide_int &val)
{
- r = value_range_base (type, min_limit (type), val);
+ r = value_range (type, min_limit (type), val);
}
// (X > VAL) produces the range of [VAL + 1, MAX].
static void
-build_gt (value_range_base &r, tree type, const wide_int &val)
+build_gt (value_range &r, tree type, const wide_int &val)
{
wi::overflow_type ov;
wide_int lim = wi::add (val, 1, TYPE_SIGN (type), &ov);
@@ -559,38 +556,38 @@ build_gt (value_range_base &r, tree type, const wide_int &val)
if (ov)
r.set_undefined ();
else
- r = value_range_base (type, lim, max_limit (type));
+ r = value_range (type, lim, max_limit (type));
}
// (X >= val) produces the range of [VAL, MAX].
static void
-build_ge (value_range_base &r, tree type, const wide_int &val)
+build_ge (value_range &r, tree type, const wide_int &val)
{
- r = value_range_base (type, val, max_limit (type));
+ r = value_range (type, val, max_limit (type));
}
class operator_lt : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- 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 value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) 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;
} op_lt;
-value_range_base
+value_range
operator_lt::fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const
+ const value_range &op1,
+ const value_range &op2) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, op1, op2))
return r;
@@ -607,9 +604,9 @@ operator_lt::fold_range (tree type,
}
bool
-operator_lt::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_lt::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -628,9 +625,9 @@ operator_lt::op1_range (value_range_base &r, tree type,
}
bool
-operator_lt::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_lt::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -652,23 +649,23 @@ operator_lt::op2_range (value_range_base &r, tree type,
class operator_le : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- 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 value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) 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;
} op_le;
-value_range_base
+value_range
operator_le::fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const
+ const value_range &op1,
+ const value_range &op2) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, op1, op2))
return r;
@@ -685,9 +682,9 @@ operator_le::fold_range (tree type,
}
bool
-operator_le::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_le::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -706,9 +703,9 @@ operator_le::op1_range (value_range_base &r, tree type,
}
bool
-operator_le::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_le::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -730,23 +727,22 @@ operator_le::op2_range (value_range_base &r, tree type,
class operator_gt : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- 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 value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) 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;
} op_gt;
-value_range_base
+value_range
operator_gt::fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const
+ const value_range &op1, const value_range &op2) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, op1, op2))
return r;
@@ -763,9 +759,8 @@ operator_gt::fold_range (tree type,
}
bool
-operator_gt::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_gt::op1_range (value_range &r, tree type,
+ const value_range &lhs, const value_range &op2) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -784,9 +779,9 @@ operator_gt::op1_range (value_range_base &r, tree type,
}
bool
-operator_gt::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_gt::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -808,23 +803,23 @@ operator_gt::op2_range (value_range_base &r, tree type,
class operator_ge : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- 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 value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) 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;
} op_ge;
-value_range_base
+value_range
operator_ge::fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const
+ const value_range &op1,
+ const value_range &op2) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, op1, op2))
return r;
@@ -841,9 +836,9 @@ operator_ge::fold_range (tree type,
}
bool
-operator_ge::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_ge::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -862,9 +857,9 @@ operator_ge::op1_range (value_range_base &r, tree type,
}
bool
-operator_ge::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_ge::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -886,20 +881,20 @@ operator_ge::op2_range (value_range_base &r, tree type,
class operator_plus : public range_operator
{
public:
- 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 value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) 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;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_plus;
-value_range_base
+value_range
operator_plus::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
@@ -912,18 +907,18 @@ operator_plus::wi_fold (tree type,
}
bool
-operator_plus::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_plus::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
r = range_op_handler (MINUS_EXPR, type)->fold_range (type, lhs, op2);
return true;
}
bool
-operator_plus::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_plus::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
r = range_op_handler (MINUS_EXPR, type)->fold_range (type, lhs, op1);
return true;
@@ -933,20 +928,20 @@ operator_plus::op2_range (value_range_base &r, tree type,
class operator_minus : public range_operator
{
public:
- 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 value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) 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;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_minus;
-value_range_base
+value_range
operator_minus::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
@@ -959,18 +954,18 @@ operator_minus::wi_fold (tree type,
}
bool
-operator_minus::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_minus::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
r = range_op_handler (PLUS_EXPR, type)->fold_range (type, lhs, op2);
return true;
}
bool
-operator_minus::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_minus::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
r = fold_range (type, op1, lhs);
return true;
@@ -980,14 +975,14 @@ operator_minus::op2_range (value_range_base &r, tree type,
class operator_min : public range_operator
{
public:
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_min;
-value_range_base
+value_range
operator_min::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
@@ -1002,14 +997,14 @@ operator_min::wi_fold (tree type,
class operator_max : public range_operator
{
public:
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_max;
-value_range_base
+value_range
operator_max::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
@@ -1032,7 +1027,7 @@ public:
const wide_int &) const = 0;
// Calculate the cross product of two sets of sub-ranges and return it.
- value_range_base wi_cross_product (tree type,
+ value_range wi_cross_product (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
@@ -1052,7 +1047,7 @@ public:
// MIN1, MIN0 OP MAX1, MAX0 OP MIN1 and MAX0 OP MAX0 OP MAX1) and then
// figure the smallest and largest values to form the new range.
-value_range_base
+value_range
cross_product_operator::wi_cross_product (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
@@ -1064,19 +1059,19 @@ cross_product_operator::wi_cross_product (tree type,
// Compute the 4 cross operations, bailing if we get an overflow we
// can't handle.
if (wi_op_overflows (cp1, type, lh_lb, rh_lb))
- return value_range_base (type);
+ return value_range (type);
if (wi::eq_p (lh_lb, lh_ub))
cp3 = cp1;
else if (wi_op_overflows (cp3, type, lh_ub, rh_lb))
- return value_range_base (type);
+ return value_range (type);
if (wi::eq_p (rh_lb, rh_ub))
cp2 = cp1;
else if (wi_op_overflows (cp2, type, lh_lb, rh_ub))
- return value_range_base (type);
+ return value_range (type);
if (wi::eq_p (lh_lb, lh_ub))
cp4 = cp2;
else if (wi_op_overflows (cp4, type, lh_ub, rh_ub))
- return value_range_base (type);
+ return value_range (type);
// Order pairs.
signop sign = TYPE_SIGN (type);
@@ -1095,22 +1090,18 @@ cross_product_operator::wi_cross_product (tree type,
class operator_mult : public cross_product_operator
{
public:
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
- virtual bool wi_op_overflows (wide_int &res,
- tree type,
- const wide_int &w0,
- const wide_int &w1) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
+ virtual bool wi_op_overflows (wide_int &res, tree type,
+ const wide_int &w0, const wide_int &w1) const;
} op_mult;
bool
-operator_mult::wi_op_overflows (wide_int &res,
- tree type,
- const wide_int &w0,
- const wide_int &w1) const
+operator_mult::wi_op_overflows (wide_int &res, tree type,
+ const wide_int &w0, const wide_int &w1) const
{
wi::overflow_type overflow = wi::OVF_NONE;
signop sign = TYPE_SIGN (type);
@@ -1128,7 +1119,7 @@ operator_mult::wi_op_overflows (wide_int &res,
return overflow;
}
-value_range_base
+value_range
operator_mult::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
@@ -1195,7 +1186,7 @@ operator_mult::wi_fold (tree type,
prod2 = prod3 - prod0;
if (wi::geu_p (prod2, sizem1))
// The range covers all values.
- return value_range_base (type);
+ return value_range (type);
wide_int new_lb = wide_int::from (prod0, prec, sign);
wide_int new_ub = wide_int::from (prod3, prec, sign);
@@ -1207,24 +1198,20 @@ class operator_div : public cross_product_operator
{
public:
operator_div (enum tree_code c) { code = c; }
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
- virtual bool wi_op_overflows (wide_int &res,
- tree type,
- const wide_int &,
- const wide_int &) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
+ virtual bool wi_op_overflows (wide_int &res, tree type,
+ const wide_int &, const wide_int &) const;
private:
enum tree_code code;
};
bool
-operator_div::wi_op_overflows (wide_int &res,
- tree type,
- const wide_int &w0,
- const wide_int &w1) const
+operator_div::wi_op_overflows (wide_int &res, tree type,
+ const wide_int &w0, const wide_int &w1) const
{
if (w1 == 0)
return true;
@@ -1264,14 +1251,14 @@ operator_div::wi_op_overflows (wide_int &res,
return overflow;
}
-value_range_base
+value_range
operator_div::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
{
// If we know we will divide by zero, return undefined.
if (rh_lb == 0 && rh_ub == 0)
- return value_range_base ();
+ return value_range ();
const wide_int dividend_min = lh_lb;
const wide_int dividend_max = lh_ub;
@@ -1288,24 +1275,24 @@ operator_div::wi_fold (tree type,
// If flag_non_call_exceptions, we must not eliminate a division by zero.
if (cfun->can_throw_non_call_exceptions)
- return value_range_base (type);
+ return value_range (type);
// If we're definitely dividing by zero, there's nothing to do.
if (wi_zero_p (type, divisor_min, divisor_max))
- return value_range_base ();
+ return value_range ();
// Perform the division in 2 parts, [LB, -1] and [1, UB], which will
// skip any division by zero.
// First divide by the negative numbers, if any.
- value_range_base r;
+ value_range r;
if (wi::neg_p (divisor_min, sign))
r = wi_cross_product (type, dividend_min, dividend_max,
divisor_min, wi::minus_one (prec));
// Then divide by the non-zero positive numbers, if any.
if (wi::gt_p (divisor_max, wi::zero (prec), sign))
{
- value_range_base tmp;
+ value_range tmp;
tmp = wi_cross_product (type, dividend_min, dividend_max,
wi::one (prec), divisor_max);
r.union_ (tmp);
@@ -1323,16 +1310,16 @@ class operator_exact_divide : public operator_div
{
public:
operator_exact_divide () : operator_div (TRUNC_DIV_EXPR) { }
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const;
} op_exact_div;
bool
-operator_exact_divide::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_exact_divide::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
tree offset;
// [2, 4] = op1 / [3,3] since its exact divide, no need to worry about
@@ -1354,11 +1341,11 @@ operator_exact_divide::op1_range (value_range_base &r, tree type,
class operator_lshift : public cross_product_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
+ virtual value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) const;
- 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, const wide_int &rh_ub) const;
virtual bool wi_op_overflows (wide_int &res,
@@ -1367,12 +1354,12 @@ public:
const wide_int &) const;
} op_lshift;
-value_range_base
+value_range
operator_lshift::fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const
+ const value_range &op1,
+ const value_range &op2) const
{
- value_range_base r;
+ value_range r;
if (undefined_shift_range_check (r, type, op2))
return r;
@@ -1381,7 +1368,7 @@ operator_lshift::fold_range (tree type,
{
unsigned shift = op2.lower_bound ().to_uhwi ();
wide_int tmp = wi::set_bit_in_zero (shift, TYPE_PRECISION (type));
- value_range_base mult (type, tmp, tmp);
+ value_range mult (type, tmp, tmp);
// Force wrapping multiplication.
bool saved_flag_wrapv = flag_wrapv;
@@ -1398,7 +1385,7 @@ operator_lshift::fold_range (tree type,
return range_operator::fold_range (type, op1, op2);
}
-value_range_base
+value_range
operator_lshift::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
@@ -1455,14 +1442,12 @@ operator_lshift::wi_fold (tree type,
if (in_bounds)
return wi_cross_product (type, lh_lb, lh_ub, rh_lb, rh_ub);
- return value_range_base (type);
+ return value_range (type);
}
bool
-operator_lshift::wi_op_overflows (wide_int &res,
- tree type,
- const wide_int &w0,
- const wide_int &w1) const
+operator_lshift::wi_op_overflows (wide_int &res, tree type,
+ const wide_int &w0, const wide_int &w1) const
{
signop sign = TYPE_SIGN (type);
if (wi::neg_p (w1))
@@ -1481,12 +1466,14 @@ operator_lshift::wi_op_overflows (wide_int &res,
class operator_rshift : public cross_product_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb, const wide_int &lh_ub,
- const wide_int &rh_lb, const wide_int &rh_ub) const;
+ virtual value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
virtual bool wi_op_overflows (wide_int &res,
tree type,
const wide_int &w0,
@@ -1512,12 +1499,12 @@ operator_rshift::wi_op_overflows (wide_int &res,
return false;
}
-value_range_base
+value_range
operator_rshift::fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const
+ const value_range &op1,
+ const value_range &op2) const
{
- value_range_base r;
+ value_range r;
if (undefined_shift_range_check (r, type, op2))
return r;
@@ -1525,7 +1512,7 @@ operator_rshift::fold_range (tree type,
return range_operator::fold_range (type, op1, op2);
}
-value_range_base
+value_range
operator_rshift::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const
@@ -1537,21 +1524,21 @@ operator_rshift::wi_fold (tree type,
class operator_cast: public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const;
+ virtual value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const;
} op_convert;
-value_range_base
+value_range
operator_cast::fold_range (tree type ATTRIBUTE_UNUSED,
- const value_range_base &lh,
- const value_range_base &rh) const
+ const value_range &lh,
+ const value_range &rh) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, lh, rh))
return r;
@@ -1584,21 +1571,21 @@ operator_cast::fold_range (tree type ATTRIBUTE_UNUSED,
if (!wi::eq_p (min, wi::min_value (outer_prec, outer_sign))
|| !wi::eq_p (max, wi::max_value (outer_prec, outer_sign)))
{
- value_range_base tmp;
+ value_range tmp;
tmp = create_possibly_reversed_range (type, min, max);
r.union_ (tmp);
continue;
}
}
- return value_range_base (type);
+ return value_range (type);
}
return r;
}
bool
-operator_cast::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_cast::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
tree lhs_type = lhs.type ();
gcc_checking_assert (types_compatible_p (op2.type(), type));
@@ -1612,14 +1599,14 @@ operator_cast::op1_range (value_range_base &r, tree type,
// the type, see if it fits the LHS, and if so, then we can allow
// it.
r = op2;
- r = fold_range (lhs_type, r, value_range_base (lhs_type));
- r = fold_range (type, r, value_range_base (type));
+ r = fold_range (lhs_type, r, value_range (lhs_type));
+ r = fold_range (type, r, value_range (type));
if (r == op2)
{
// We know the value of the RHS fits in the LHS type, so
// convert the LHS and remove any values that arent in OP2.
r = lhs;
- r = fold_range (type, r, value_range_base (type));
+ r = fold_range (type, r, value_range (type));
r.intersect (op2);
return true;
}
@@ -1639,11 +1626,11 @@ operator_cast::op1_range (value_range_base &r, tree type,
// *not* in the RHS is 0 or -1.
unsigned prec = TYPE_PRECISION (type);
if (lhs.zero_p ())
- r = value_range_base (VR_ANTI_RANGE, type,
- wi::minus_one (prec), wi::minus_one (prec));
+ r = value_range (VR_ANTI_RANGE, type,
+ wi::minus_one (prec), wi::minus_one (prec));
else
- r = value_range_base (VR_ANTI_RANGE, type,
- wi::zero (prec), wi::zero (prec));
+ r = value_range (VR_ANTI_RANGE, type,
+ wi::zero (prec), wi::zero (prec));
// And intersect it with what we know about op2.
r.intersect (op2);
}
@@ -1659,8 +1646,8 @@ operator_cast::op1_range (value_range_base &r, tree type,
if (TYPE_PRECISION (lhs_type) > TYPE_PRECISION (type))
{
// Cast the range of the RHS to the type of the LHS.
- value_range_base op_type (type);
- op_type = fold_range (lhs_type, op_type, value_range_base (lhs_type));
+ value_range op_type (type);
+ op_type = fold_range (lhs_type, op_type, value_range (lhs_type));
// Intersect this with the LHS range will produce the RHS range.
r = range_intersect (lhs, op_type);
@@ -1669,7 +1656,7 @@ operator_cast::op1_range (value_range_base &r, tree type,
r = lhs;
// Cast the calculated range to the type of the RHS.
- r = fold_range (type, r, value_range_base (type));
+ r = fold_range (type, r, value_range (type));
return true;
}
@@ -1677,24 +1664,24 @@ operator_cast::op1_range (value_range_base &r, tree type,
class operator_logical_and : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const;
- 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 value_range fold_range (tree type,
+ const value_range &lh,
+ const value_range &rh) 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;
} op_logical_and;
-value_range_base
+value_range
operator_logical_and::fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const
+ const value_range &lh,
+ const value_range &rh) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, lh, rh))
return r;
@@ -1713,9 +1700,9 @@ operator_logical_and::fold_range (tree type,
}
bool
-operator_logical_and::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2 ATTRIBUTE_UNUSED) const
+operator_logical_and::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2 ATTRIBUTE_UNUSED) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -1734,9 +1721,9 @@ operator_logical_and::op1_range (value_range_base &r, tree type,
}
bool
-operator_logical_and::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_logical_and::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
return operator_logical_and::op1_range (r, type, lhs, op1);
}
@@ -1745,17 +1732,17 @@ operator_logical_and::op2_range (value_range_base &r, tree type,
class operator_bitwise_and : public range_operator
{
public:
- 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 value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) 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;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_bitwise_and;
// Optimize BIT_AND_EXPR and BIT_IOR_EXPR in terms of a mask if
@@ -1769,7 +1756,7 @@ public:
// return TRUE.
static bool
-wi_optimize_and_or (value_range_base &r,
+wi_optimize_and_or (value_range &r,
enum tree_code code,
tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
@@ -1877,14 +1864,14 @@ wi_set_zero_nonzero_bits (tree type,
}
}
-value_range_base
+value_range
operator_bitwise_and::wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
const wide_int &rh_ub) const
{
- value_range_base r;
+ value_range r;
if (wi_optimize_and_or (r, BIT_AND_EXPR, type, lh_lb, lh_ub, rh_lb, rh_ub))
return r;
@@ -1931,15 +1918,15 @@ operator_bitwise_and::wi_fold (tree type,
}
// If the limits got swapped around, return varying.
if (wi::gt_p (new_lb, new_ub,sign))
- return value_range_base (type);
+ return value_range (type);
return value_range_with_overflow (type, new_lb, new_ub);
}
bool
-operator_bitwise_and::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_bitwise_and::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
// If this is really a logical wi_fold, call that.
if (types_compatible_p (type, boolean_type_node))
@@ -1951,9 +1938,9 @@ operator_bitwise_and::op1_range (value_range_base &r, tree type,
}
bool
-operator_bitwise_and::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_bitwise_and::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
return operator_bitwise_and::op1_range (r, type, lhs, op1);
}
@@ -1962,23 +1949,23 @@ operator_bitwise_and::op2_range (value_range_base &r, tree type,
class operator_logical_or : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const;
- 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 value_range fold_range (tree type,
+ const value_range &lh,
+ const value_range &rh) 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;
} op_logical_or;
-value_range_base
+value_range
operator_logical_or::fold_range (tree type ATTRIBUTE_UNUSED,
- const value_range_base &lh,
- const value_range_base &rh) const
+ const value_range &lh,
+ const value_range &rh) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, lh, rh))
return r;
@@ -1986,9 +1973,9 @@ operator_logical_or::fold_range (tree type ATTRIBUTE_UNUSED,
}
bool
-operator_logical_or::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2 ATTRIBUTE_UNUSED) const
+operator_logical_or::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2 ATTRIBUTE_UNUSED) const
{
switch (get_bool_state (r, lhs, type))
{
@@ -2007,9 +1994,9 @@ operator_logical_or::op1_range (value_range_base &r, tree type,
}
bool
-operator_logical_or::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_logical_or::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
return operator_logical_or::op1_range (r, type, lhs, op1);
}
@@ -2018,27 +2005,27 @@ operator_logical_or::op2_range (value_range_base &r, tree type,
class operator_bitwise_or : public range_operator
{
public:
- 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 value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) 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;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_bitwise_or;
-value_range_base
+value_range
operator_bitwise_or::wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
const wide_int &rh_lb,
const wide_int &rh_ub) const
{
- value_range_base r;
+ value_range r;
if (wi_optimize_and_or (r, BIT_IOR_EXPR, type, lh_lb, lh_ub, rh_lb, rh_ub))
return r;
@@ -2069,15 +2056,15 @@ operator_bitwise_or::wi_fold (tree type,
new_lb = wi::max (new_lb, rh_lb, sign);
// If the limits got swapped around, return varying.
if (wi::gt_p (new_lb, new_ub,sign))
- return value_range_base (type);
+ return value_range (type);
return value_range_with_overflow (type, new_lb, new_ub);
}
bool
-operator_bitwise_or::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_bitwise_or::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
// If this is really a logical wi_fold, call that.
if (types_compatible_p (type, boolean_type_node))
@@ -2089,9 +2076,9 @@ operator_bitwise_or::op1_range (value_range_base &r, tree type,
}
bool
-operator_bitwise_or::op2_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op1) const
+operator_bitwise_or::op2_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op1) const
{
return operator_bitwise_or::op1_range (r, type, lhs, op1);
}
@@ -2100,14 +2087,14 @@ operator_bitwise_or::op2_range (value_range_base &r, tree type,
class operator_bitwise_xor : public range_operator
{
public:
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_bitwise_xor;
-value_range_base
+value_range
operator_bitwise_xor::wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
@@ -2135,21 +2122,21 @@ operator_bitwise_xor::wi_fold (tree type,
if (wi::lt_p (new_lb, 0, sign) || wi::ge_p (new_ub, 0, sign))
return value_range_with_overflow (type, new_lb, new_ub);
- return value_range_base (type);
+ return value_range (type);
}
class operator_trunc_mod : public range_operator
{
public:
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_trunc_mod;
-value_range_base
+value_range
operator_trunc_mod::wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
@@ -2162,7 +2149,7 @@ operator_trunc_mod::wi_fold (tree type,
// Mod 0 is undefined. Return undefined.
if (wi_zero_p (type, rh_lb, rh_ub))
- return value_range_base ();
+ return value_range ();
// ABS (A % B) < ABS (B) and either 0 <= A % B <= A or A <= A % B <= 0.
new_ub = rh_ub - 1;
@@ -2194,12 +2181,12 @@ operator_trunc_mod::wi_fold (tree type,
class operator_logical_not : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const;
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const;
+ virtual value_range fold_range (tree type,
+ const value_range &lh,
+ const value_range &rh) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const;
} op_logical_not;
// Folding a logical NOT, oddly enough, involves doing nothing on the
@@ -2216,12 +2203,12 @@ public:
// b_2 = x_1 < 20 [0,0] = x_1 < 20, false, so x_1 == [20, 255]
// which is the result we are looking for.. so.. pass it through.
-value_range_base
+value_range
operator_logical_not::fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh ATTRIBUTE_UNUSED) const
+ const value_range &lh,
+ const value_range &rh ATTRIBUTE_UNUSED) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, lh, rh))
return r;
@@ -2234,10 +2221,10 @@ operator_logical_not::fold_range (tree type,
}
bool
-operator_logical_not::op1_range (value_range_base &r,
+operator_logical_not::op1_range (value_range &r,
tree type ATTRIBUTE_UNUSED,
- const value_range_base &lhs,
- const value_range_base &op2 ATTRIBUTE_UNUSED) const
+ const value_range &lhs,
+ const value_range &op2 ATTRIBUTE_UNUSED) const
{
if (lhs.varying_p () || lhs.undefined_p ())
r = lhs;
@@ -2250,35 +2237,34 @@ operator_logical_not::op1_range (value_range_base &r,
class operator_bitwise_not : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const;
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const;
+ virtual value_range fold_range (tree type,
+ const value_range &lh,
+ const value_range &rh) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const;
} op_bitwise_not;
-value_range_base
+value_range
operator_bitwise_not::fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const
+ const value_range &lh,
+ const value_range &rh) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, lh, rh))
return r;
// ~X is simply -1 - X.
- value_range_base minusone (type,
- wi::minus_one (TYPE_PRECISION (type)),
- wi::minus_one (TYPE_PRECISION (type)));
+ value_range minusone (type, wi::minus_one (TYPE_PRECISION (type)),
+ wi::minus_one (TYPE_PRECISION (type)));
r = range_op_handler (MINUS_EXPR, type)->fold_range (type, minusone, lh);
return r;
}
bool
-operator_bitwise_not::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_bitwise_not::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
// ~X is -1 - X and since bitwise NOT is involutary...do it again.
r = fold_range (type, lhs, op2);
@@ -2289,15 +2275,15 @@ operator_bitwise_not::op1_range (value_range_base &r, tree type,
class operator_cst : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
+ virtual value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) const;
} op_integer_cst;
-value_range_base
+value_range
operator_cst::fold_range (tree type ATTRIBUTE_UNUSED,
- const value_range_base &lh,
- const value_range_base &rh ATTRIBUTE_UNUSED) const
+ const value_range &lh,
+ const value_range &rh ATTRIBUTE_UNUSED) const
{
return lh;
}
@@ -2306,26 +2292,26 @@ operator_cst::fold_range (tree type ATTRIBUTE_UNUSED,
class operator_identity : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const;
+ virtual value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const;
} op_identity;
-value_range_base
+value_range
operator_identity::fold_range (tree type ATTRIBUTE_UNUSED,
- const value_range_base &lh,
- const value_range_base &rh ATTRIBUTE_UNUSED) const
+ const value_range &lh,
+ const value_range &rh ATTRIBUTE_UNUSED) const
{
return lh;
}
bool
-operator_identity::op1_range (value_range_base &r, tree type ATTRIBUTE_UNUSED,
- const value_range_base &lhs,
- const value_range_base &op2 ATTRIBUTE_UNUSED) const
+operator_identity::op1_range (value_range &r, tree type ATTRIBUTE_UNUSED,
+ const value_range &lhs,
+ const value_range &op2 ATTRIBUTE_UNUSED) const
{
r = lhs;
return true;
@@ -2335,17 +2321,17 @@ operator_identity::op1_range (value_range_base &r, tree type ATTRIBUTE_UNUSED,
class operator_abs : public range_operator
{
public:
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const;
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const;
} op_abs;
-value_range_base
+value_range
operator_abs::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb ATTRIBUTE_UNUSED,
@@ -2357,14 +2343,14 @@ operator_abs::wi_fold (tree type,
// Pass through LH for the easy cases.
if (sign == UNSIGNED || wi::ge_p (lh_lb, 0, sign))
- return value_range_base (type, lh_lb, lh_ub);
+ return value_range (type, lh_lb, lh_ub);
// -TYPE_MIN_VALUE = TYPE_MIN_VALUE with flag_wrapv so we can't get
// a useful range.
wide_int min_value = wi::min_value (prec, sign);
wide_int max_value = wi::max_value (prec, sign);
if (!TYPE_OVERFLOW_UNDEFINED (type) && wi::eq_p (lh_lb, min_value))
- return value_range_base (type);
+ return value_range (type);
// ABS_EXPR may flip the range around, if the original range
// included negative values.
@@ -2400,13 +2386,13 @@ operator_abs::wi_fold (tree type,
min = wi::zero (prec);
max = max_value;
}
- return value_range_base (type, min, max);
+ return value_range (type, min, max);
}
bool
-operator_abs::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_abs::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
if (empty_range_check (r, lhs, op2))
return true;
@@ -2416,15 +2402,15 @@ operator_abs::op1_range (value_range_base &r, tree type,
return true;
}
// Start with the positives because negatives are an impossible result.
- value_range_base positives = range_positives (type);
+ value_range positives = range_positives (type);
positives.intersect (lhs);
r = positives;
// Then add the negative of each pair:
// ABS(op1) = [5,20] would yield op1 => [-20,-5][5,20].
for (unsigned i = 0; i < positives.num_pairs (); ++i)
- r.union_ (value_range_base (type,
- -positives.upper_bound (i),
- -positives.lower_bound (i)));
+ r.union_ (value_range (type,
+ -positives.upper_bound (i),
+ -positives.lower_bound (i)));
return true;
}
@@ -2432,12 +2418,12 @@ operator_abs::op1_range (value_range_base &r, tree type,
class operator_absu : public range_operator
{
public:
- 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, const wide_int &rh_ub) const;
} op_absu;
-value_range_base
+value_range
operator_absu::wi_fold (tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb ATTRIBUTE_UNUSED,
@@ -2469,27 +2455,27 @@ operator_absu::wi_fold (tree type,
}
gcc_checking_assert (TYPE_UNSIGNED (type));
- return value_range_base (type, new_lb, new_ub);
+ return value_range (type, new_lb, new_ub);
}
class operator_negate : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const;
+ virtual value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const;
} op_negate;
-value_range_base
+value_range
operator_negate::fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const
+ const value_range &lh,
+ const value_range &rh) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, lh, rh))
return r;
// -X is simply 0 - X.
@@ -2499,9 +2485,9 @@ operator_negate::fold_range (tree type,
}
bool
-operator_negate::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_negate::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
// NEGATE is involutory.
r = fold_range (type, lhs, op2);
@@ -2512,20 +2498,20 @@ operator_negate::op1_range (value_range_base &r, tree type,
class operator_addr_expr : public range_operator
{
public:
- virtual value_range_base fold_range (tree type,
- const value_range_base &op1,
- const value_range_base &op2) const;
- virtual bool op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const;
+ virtual value_range fold_range (tree type,
+ const value_range &op1,
+ const value_range &op2) const;
+ virtual bool op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const;
} op_addr;
-value_range_base
+value_range
operator_addr_expr::fold_range (tree type,
- const value_range_base &lh,
- const value_range_base &rh) const
+ const value_range &lh,
+ const value_range &rh) const
{
- value_range_base r;
+ value_range r;
if (empty_range_check (r, lh, rh))
return r;
@@ -2534,13 +2520,13 @@ operator_addr_expr::fold_range (tree type,
return range_zero (type);
if (!lh.contains_p (build_zero_cst (lh.type ())))
return range_nonzero (type);
- return value_range_base (type);
+ return value_range (type);
}
bool
-operator_addr_expr::op1_range (value_range_base &r, tree type,
- const value_range_base &lhs,
- const value_range_base &op2) const
+operator_addr_expr::op1_range (value_range &r, tree type,
+ const value_range &lhs,
+ const value_range &op2) const
{
r = operator_addr_expr::fold_range (type, lhs, op2);
return true;
@@ -2550,12 +2536,14 @@ operator_addr_expr::op1_range (value_range_base &r, tree type,
class pointer_plus_operator : public range_operator
{
public:
- virtual value_range_base wi_fold (tree type,
- const wide_int &lh_lb, const wide_int &lh_ub,
- const wide_int &rh_lb, const wide_int &rh_ub) const;
+ virtual value_range wi_fold (tree type,
+ const wide_int &lh_lb,
+ const wide_int &lh_ub,
+ const wide_int &rh_lb,
+ const wide_int &rh_ub) const;
} op_pointer_plus;
-value_range_base
+value_range
pointer_plus_operator::wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
@@ -2587,19 +2575,19 @@ pointer_plus_operator::wi_fold (tree type,
if (lh_lb == lh_ub && lh_lb == 0
&& rh_lb == rh_ub && rh_lb == 0)
return range_zero (type);
- return value_range_base (type);
+ return value_range (type);
}
class pointer_min_max_operator : public range_operator
{
public:
- 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, const wide_int &rh_ub) const;
} op_ptr_min_max;
-value_range_base
+value_range
pointer_min_max_operator::wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
@@ -2615,19 +2603,19 @@ pointer_min_max_operator::wi_fold (tree type,
return range_nonzero (type);
if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
return range_zero (type);
- return value_range_base (type);
+ return value_range (type);
}
class pointer_and_operator : public range_operator
{
public:
- 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, const wide_int &rh_ub) const;
} op_pointer_and;
-value_range_base
+value_range
pointer_and_operator::wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
@@ -2639,19 +2627,19 @@ pointer_and_operator::wi_fold (tree type,
if (wi_zero_p (type, lh_lb, lh_ub) || wi_zero_p (type, lh_lb, lh_ub))
return range_zero (type);
- return value_range_base (type);
+ return value_range (type);
}
class pointer_or_operator : public range_operator
{
public:
- 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, const wide_int &rh_ub) const;
} op_pointer_or;
-value_range_base
+value_range
pointer_or_operator::wi_fold (tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
@@ -2665,7 +2653,7 @@ pointer_or_operator::wi_fold (tree type,
return range_nonzero (type);
if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
return range_zero (type);
- return value_range_base (type);
+ return value_range (type);
}
// This implements the range operator tables as local objects in this file.
@@ -2792,10 +2780,10 @@ range_op_handler (enum tree_code code, tree type)
// Cast the range in R to TYPE.
void
-range_cast (value_range_base &r, tree type)
+range_cast (value_range &r, tree type)
{
range_operator *op = range_op_handler (CONVERT_EXPR, type);
- r = op->fold_range (type, r, value_range_base (type));
+ r = op->fold_range (type, r, value_range (type));
}
#if CHECKING_P
@@ -2803,8 +2791,8 @@ range_cast (value_range_base &r, tree type)
#include "stor-layout.h"
// Ideally this should go in namespace selftest, but range_tests
-// needs to be a friend of class value_range_base so it can access
-// value_range_base::m_max_pairs.
+// needs to be a friend of class value_range so it can access
+// value_range::m_max_pairs.
#define INT(N) build_int_cst (integer_type_node, (N))
#define UINT(N) build_int_cstu (unsigned_type_node, (N))
@@ -2817,9 +2805,9 @@ range_cast (value_range_base &r, tree type)
#define SCHAR(N) build_int_cst (signed_char_type_node, (N))
#define RANGE3(A,B,C,D,E,F) \
-( i1 = value_range_base (INT (A), INT (B)), \
- i2 = value_range_base (INT (C), INT (D)), \
- i3 = value_range_base (INT (E), INT (F)), \
+( i1 = value_range (INT (A), INT (B)), \
+ i2 = value_range (INT (C), INT (D)), \
+ i3 = value_range (INT (E), INT (F)), \
i1.union_ (i2), \
i1.union_ (i3), \
i1 )
@@ -2830,28 +2818,28 @@ void
range_tests ()
{
tree u128_type = build_nonstandard_integer_type (128, /*unsigned=*/1);
- value_range_base i1, i2, i3;
- value_range_base r0, r1, rold;
+ value_range i1, i2, i3;
+ value_range r0, r1, rold;
// Test that NOT(255) is [0..254] in 8-bit land.
- value_range_base not_255 (VR_ANTI_RANGE, UCHAR (255), UCHAR (255));
- ASSERT_TRUE (not_255 == value_range_base (UCHAR (0), UCHAR (254)));
+ value_range not_255 (VR_ANTI_RANGE, UCHAR (255), UCHAR (255));
+ ASSERT_TRUE (not_255 == value_range (UCHAR (0), UCHAR (254)));
// Test that NOT(0) is [1..255] in 8-bit land.
- value_range_base not_zero = range_nonzero (unsigned_char_type_node);
- ASSERT_TRUE (not_zero == value_range_base (UCHAR (1), UCHAR (255)));
+ value_range not_zero = range_nonzero (unsigned_char_type_node);
+ ASSERT_TRUE (not_zero == value_range (UCHAR (1), UCHAR (255)));
// Check that [0,127][0x..ffffff80,0x..ffffff]
// => ~[128, 0x..ffffff7f].
- r0 = value_range_base (UINT128 (0), UINT128 (127));
+ r0 = value_range (UINT128 (0), UINT128 (127));
tree high = build_minus_one_cst (u128_type);
// low = -1 - 127 => 0x..ffffff80.
tree low = fold_build2 (MINUS_EXPR, u128_type, high, UINT128(127));
- r1 = value_range_base (low, high); // [0x..ffffff80, 0x..ffffffff]
+ r1 = value_range (low, high); // [0x..ffffff80, 0x..ffffffff]
// r0 = [0,127][0x..ffffff80,0x..fffffff].
r0.union_ (r1);
// r1 = [128, 0x..ffffff7f].
- r1 = value_range_base (UINT128(128),
+ r1 = value_range (UINT128(128),
fold_build2 (MINUS_EXPR, u128_type,
build_minus_one_cst (u128_type),
UINT128(128)));
@@ -2870,41 +2858,41 @@ range_tests ()
tree maxuint = wide_int_to_tree (unsigned_type_node, r0.upper_bound ());
// Check that ~[0,5] => [6,MAX] for unsigned int.
- r0 = value_range_base (UINT (0), UINT (5));
+ r0 = value_range (UINT (0), UINT (5));
r0.invert ();
- ASSERT_TRUE (r0 == value_range_base (UINT(6), maxuint));
+ ASSERT_TRUE (r0 == value_range (UINT(6), maxuint));
// Check that ~[10,MAX] => [0,9] for unsigned int.
- r0 = value_range_base (VR_RANGE, UINT(10), maxuint);
+ r0 = value_range (VR_RANGE, UINT(10), maxuint);
r0.invert ();
- ASSERT_TRUE (r0 == value_range_base (UINT (0), UINT (9)));
+ ASSERT_TRUE (r0 == value_range (UINT (0), UINT (9)));
// Check that ~[0,5] => [6,MAX] for unsigned 128-bit numbers.
- r0 = value_range_base (VR_ANTI_RANGE, UINT128 (0), UINT128 (5));
- r1 = value_range_base (UINT128(6), build_minus_one_cst (u128_type));
+ r0 = value_range (VR_ANTI_RANGE, UINT128 (0), UINT128 (5));
+ r1 = value_range (UINT128(6), build_minus_one_cst (u128_type));
ASSERT_TRUE (r0 == r1);
// Check that [~5] is really [-MIN,4][6,MAX].
- r0 = value_range_base (VR_ANTI_RANGE, INT (5), INT (5));
- r1 = value_range_base (minint, INT (4));
- r1.union_ (value_range_base (INT (6), maxint));
+ r0 = value_range (VR_ANTI_RANGE, INT (5), INT (5));
+ r1 = value_range (minint, INT (4));
+ r1.union_ (value_range (INT (6), maxint));
ASSERT_FALSE (r1.undefined_p ());
ASSERT_TRUE (r0 == r1);
- r1 = value_range_base (INT (5), INT (5));
+ r1 = value_range (INT (5), INT (5));
r1.check ();
- value_range_base r2 (r1);
+ value_range r2 (r1);
ASSERT_TRUE (r1 == r2);
- r1 = value_range_base (INT (5), INT (10));
+ r1 = value_range (INT (5), INT (10));
r1.check ();
- r1 = value_range_base (integer_type_node,
+ r1 = value_range (integer_type_node,
wi::to_wide (INT (5)), wi::to_wide (INT (10)));
r1.check ();
ASSERT_TRUE (r1.contains_p (INT (7)));
- r1 = value_range_base (SCHAR (0), SCHAR (20));
+ r1 = value_range (SCHAR (0), SCHAR (20));
ASSERT_TRUE (r1.contains_p (SCHAR(15)));
ASSERT_FALSE (r1.contains_p (SCHAR(300)));
@@ -2913,96 +2901,96 @@ range_tests ()
if (TYPE_PRECISION (TREE_TYPE (maxint))
> TYPE_PRECISION (short_integer_type_node))
{
- r1 = value_range_base (integer_zero_node, maxint);
+ r1 = value_range (integer_zero_node, maxint);
range_cast (r1, short_integer_type_node);
ASSERT_TRUE (r1.lower_bound () == wi::to_wide (minshort)
&& r1.upper_bound() == wi::to_wide (maxshort));
}
// (unsigned char)[-5,-1] => [251,255].
- r0 = rold = value_range_base (SCHAR (-5), SCHAR (-1));
+ r0 = rold = value_range (SCHAR (-5), SCHAR (-1));
range_cast (r0, unsigned_char_type_node);
- ASSERT_TRUE (r0 == value_range_base (UCHAR (251), UCHAR (255)));
+ ASSERT_TRUE (r0 == value_range (UCHAR (251), UCHAR (255)));
range_cast (r0, signed_char_type_node);
ASSERT_TRUE (r0 == rold);
// (signed char)[15, 150] => [-128,-106][15,127].
- r0 = rold = value_range_base (UCHAR (15), UCHAR (150));
+ r0 = rold = value_range (UCHAR (15), UCHAR (150));
range_cast (r0, signed_char_type_node);
- r1 = value_range_base (SCHAR (15), SCHAR (127));
- r2 = value_range_base (SCHAR (-128), SCHAR (-106));
+ r1 = value_range (SCHAR (15), SCHAR (127));
+ r2 = value_range (SCHAR (-128), SCHAR (-106));
r1.union_ (r2);
ASSERT_TRUE (r1 == r0);
range_cast (r0, unsigned_char_type_node);
ASSERT_TRUE (r0 == rold);
// (unsigned char)[-5, 5] => [0,5][251,255].
- r0 = rold = value_range_base (SCHAR (-5), SCHAR (5));
+ r0 = rold = value_range (SCHAR (-5), SCHAR (5));
range_cast (r0, unsigned_char_type_node);
- r1 = value_range_base (UCHAR (251), UCHAR (255));
- r2 = value_range_base (UCHAR (0), UCHAR (5));
+ r1 = value_range (UCHAR (251), UCHAR (255));
+ r2 = value_range (UCHAR (0), UCHAR (5));
r1.union_ (r2);
ASSERT_TRUE (r0 == r1);
range_cast (r0, signed_char_type_node);
ASSERT_TRUE (r0 == rold);
// (unsigned char)[-5,5] => [0,5][251,255].
- r0 = value_range_base (INT (-5), INT (5));
+ r0 = value_range (INT (-5), INT (5));
range_cast (r0, unsigned_char_type_node);
- r1 = value_range_base (UCHAR (0), UCHAR (5));
- r1.union_ (value_range_base (UCHAR (251), UCHAR (255)));
+ r1 = value_range (UCHAR (0), UCHAR (5));
+ r1.union_ (value_range (UCHAR (251), UCHAR (255)));
ASSERT_TRUE (r0 == r1);
// (unsigned char)[5U,1974U] => [0,255].
- r0 = value_range_base (UINT (5), UINT (1974));
+ r0 = value_range (UINT (5), UINT (1974));
range_cast (r0, unsigned_char_type_node);
- ASSERT_TRUE (r0 == value_range_base (UCHAR (0), UCHAR (255)));
+ ASSERT_TRUE (r0 == value_range (UCHAR (0), UCHAR (255)));
range_cast (r0, integer_type_node);
// Going to a wider range should not sign extend.
- ASSERT_TRUE (r0 == value_range_base (INT (0), INT (255)));
+ ASSERT_TRUE (r0 == value_range (INT (0), INT (255)));
// (unsigned char)[-350,15] => [0,255].
- r0 = value_range_base (INT (-350), INT (15));
+ r0 = value_range (INT (-350), INT (15));
range_cast (r0, unsigned_char_type_node);
- ASSERT_TRUE (r0 == (value_range_base
+ ASSERT_TRUE (r0 == (value_range
(TYPE_MIN_VALUE (unsigned_char_type_node),
TYPE_MAX_VALUE (unsigned_char_type_node))));
// Casting [-120,20] from signed char to unsigned short.
// => [0, 20][0xff88, 0xffff].
- r0 = value_range_base (SCHAR (-120), SCHAR (20));
+ r0 = value_range (SCHAR (-120), SCHAR (20));
range_cast (r0, short_unsigned_type_node);
- r1 = value_range_base (UINT16 (0), UINT16 (20));
- r2 = value_range_base (UINT16 (0xff88), UINT16 (0xffff));
+ r1 = value_range (UINT16 (0), UINT16 (20));
+ r2 = value_range (UINT16 (0xff88), UINT16 (0xffff));
r1.union_ (r2);
ASSERT_TRUE (r0 == r1);
// A truncating cast back to signed char will work because [-120, 20]
// is representable in signed char.
range_cast (r0, signed_char_type_node);
- ASSERT_TRUE (r0 == value_range_base (SCHAR (-120), SCHAR (20)));
+ ASSERT_TRUE (r0 == value_range (SCHAR (-120), SCHAR (20)));
// unsigned char -> signed short
// (signed short)[(unsigned char)25, (unsigned char)250]
// => [(signed short)25, (signed short)250]
- r0 = rold = value_range_base (UCHAR (25), UCHAR (250));
+ r0 = rold = value_range (UCHAR (25), UCHAR (250));
range_cast (r0, short_integer_type_node);
- r1 = value_range_base (INT16 (25), INT16 (250));
+ r1 = value_range (INT16 (25), INT16 (250));
ASSERT_TRUE (r0 == r1);
range_cast (r0, unsigned_char_type_node);
ASSERT_TRUE (r0 == rold);
// Test casting a wider signed [-MIN,MAX] to a nar`rower unsigned.
- r0 = value_range_base (TYPE_MIN_VALUE (long_long_integer_type_node),
+ r0 = value_range (TYPE_MIN_VALUE (long_long_integer_type_node),
TYPE_MAX_VALUE (long_long_integer_type_node));
range_cast (r0, short_unsigned_type_node);
- r1 = value_range_base (TYPE_MIN_VALUE (short_unsigned_type_node),
+ r1 = value_range (TYPE_MIN_VALUE (short_unsigned_type_node),
TYPE_MAX_VALUE (short_unsigned_type_node));
ASSERT_TRUE (r0 == r1);
// NOT([10,20]) ==> [-MIN,9][21,MAX].
- r0 = r1 = value_range_base (INT (10), INT (20));
- r2 = value_range_base (minint, INT(9));
- r2.union_ (value_range_base (INT(21), maxint));
+ r0 = r1 = value_range (INT (10), INT (20));
+ r2 = value_range (minint, INT(9));
+ r2.union_ (value_range (INT(21), maxint));
ASSERT_FALSE (r2.undefined_p ());
r1.invert ();
ASSERT_TRUE (r1 == r2);
@@ -3012,10 +3000,10 @@ range_tests ()
// Test that booleans and their inverse work as expected.
r0 = range_zero (boolean_type_node);
- ASSERT_TRUE (r0 == value_range_base (build_zero_cst (boolean_type_node),
+ ASSERT_TRUE (r0 == value_range (build_zero_cst (boolean_type_node),
build_zero_cst (boolean_type_node)));
r0.invert ();
- ASSERT_TRUE (r0 == value_range_base (build_one_cst (boolean_type_node),
+ ASSERT_TRUE (r0 == value_range (build_one_cst (boolean_type_node),
build_one_cst (boolean_type_node)));
// Casting NONZERO to a narrower type will wrap/overflow so
@@ -3029,7 +3017,7 @@ range_tests ()
{
r0 = range_nonzero (integer_type_node);
range_cast (r0, short_integer_type_node);
- r1 = value_range_base (TYPE_MIN_VALUE (short_integer_type_node),
+ r1 = value_range (TYPE_MIN_VALUE (short_integer_type_node),
TYPE_MAX_VALUE (short_integer_type_node));
ASSERT_TRUE (r0 == r1);
}
@@ -3040,45 +3028,45 @@ range_tests ()
// Converting this to 32-bits signed is [-MIN_16,-1][1, +MAX_16].
r0 = range_nonzero (short_integer_type_node);
range_cast (r0, integer_type_node);
- r1 = value_range_base (INT (-32768), INT (-1));
- r2 = value_range_base (INT (1), INT (32767));
+ r1 = value_range (INT (-32768), INT (-1));
+ r2 = value_range (INT (1), INT (32767));
r1.union_ (r2);
ASSERT_TRUE (r0 == r1);
- if (value_range_base::m_max_pairs > 2)
+ if (value_range::m_max_pairs > 2)
{
// ([10,20] U [5,8]) U [1,3] ==> [1,3][5,8][10,20].
- r0 = value_range_base (INT (10), INT (20));
- r1 = value_range_base (INT (5), INT (8));
+ r0 = value_range (INT (10), INT (20));
+ r1 = value_range (INT (5), INT (8));
r0.union_ (r1);
- r1 = value_range_base (INT (1), INT (3));
+ r1 = value_range (INT (1), INT (3));
r0.union_ (r1);
ASSERT_TRUE (r0 == RANGE3 (1, 3, 5, 8, 10, 20));
// [1,3][5,8][10,20] U [-5,0] => [-5,3][5,8][10,20].
- r1 = value_range_base (INT (-5), INT (0));
+ r1 = value_range (INT (-5), INT (0));
r0.union_ (r1);
ASSERT_TRUE (r0 == RANGE3 (-5, 3, 5, 8, 10, 20));
}
// [10,20] U [30,40] ==> [10,20][30,40].
- r0 = value_range_base (INT (10), INT (20));
- r1 = value_range_base (INT (30), INT (40));
+ r0 = value_range (INT (10), INT (20));
+ r1 = value_range (INT (30), INT (40));
r0.union_ (r1);
- ASSERT_TRUE (r0 == range_union (value_range_base (INT (10), INT (20)),
- value_range_base (INT (30), INT (40))));
- if (value_range_base::m_max_pairs > 2)
+ ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)),
+ value_range (INT (30), INT (40))));
+ if (value_range::m_max_pairs > 2)
{
// [10,20][30,40] U [50,60] ==> [10,20][30,40][50,60].
- r1 = value_range_base (INT (50), INT (60));
+ r1 = value_range (INT (50), INT (60));
r0.union_ (r1);
ASSERT_TRUE (r0 == RANGE3 (10, 20, 30, 40, 50, 60));
// [10,20][30,40][50,60] U [70, 80] ==> [10,20][30,40][50,60][70,80].
- r1 = value_range_base (INT (70), INT (80));
+ r1 = value_range (INT (70), INT (80));
r0.union_ (r1);
r2 = RANGE3 (10, 20, 30, 40, 50, 60);
- r2.union_ (value_range_base (INT (70), INT (80)));
+ r2.union_ (value_range (INT (70), INT (80)));
ASSERT_TRUE (r0 == r2);
}
@@ -3091,107 +3079,107 @@ range_tests ()
r0.invert ();
ASSERT_TRUE (r0 == r1);
- if (value_range_base::m_max_pairs > 2)
+ if (value_range::m_max_pairs > 2)
{
// [10,20][30,40][50,60] U [6,35] => [6,40][50,60].
r0 = RANGE3 (10, 20, 30, 40, 50, 60);
- r1 = value_range_base (INT (6), INT (35));
+ r1 = value_range (INT (6), INT (35));
r0.union_ (r1);
- ASSERT_TRUE (r0 == range_union (value_range_base (INT (6), INT (40)),
- value_range_base (INT (50), INT (60))));
+ ASSERT_TRUE (r0 == range_union (value_range (INT (6), INT (40)),
+ value_range (INT (50), INT (60))));
// [10,20][30,40][50,60] U [6,60] => [6,60].
r0 = RANGE3 (10, 20, 30, 40, 50, 60);
- r1 = value_range_base (INT (6), INT (60));
+ r1 = value_range (INT (6), INT (60));
r0.union_ (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (6), INT (60)));
+ ASSERT_TRUE (r0 == value_range (INT (6), INT (60)));
// [10,20][30,40][50,60] U [6,70] => [6,70].
r0 = RANGE3 (10, 20, 30, 40, 50, 60);
- r1 = value_range_base (INT (6), INT (70));
+ r1 = value_range (INT (6), INT (70));
r0.union_ (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (6), INT (70)));
+ ASSERT_TRUE (r0 == value_range (INT (6), INT (70)));
// [10,20][30,40][50,60] U [35,70] => [10,20][30,70].
r0 = RANGE3 (10, 20, 30, 40, 50, 60);
- r1 = value_range_base (INT (35), INT (70));
+ r1 = value_range (INT (35), INT (70));
r0.union_ (r1);
- ASSERT_TRUE (r0 == range_union (value_range_base (INT (10), INT (20)),
- value_range_base (INT (30), INT (70))));
+ ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)),
+ value_range (INT (30), INT (70))));
}
// [10,20][30,40] U [25,70] => [10,70].
- r0 = range_union (value_range_base (INT (10), INT (20)),
- value_range_base (INT (30), INT (40)));
- r1 = value_range_base (INT (25), INT (70));
+ r0 = range_union (value_range (INT (10), INT (20)),
+ value_range (INT (30), INT (40)));
+ r1 = value_range (INT (25), INT (70));
r0.union_ (r1);
- ASSERT_TRUE (r0 == range_union (value_range_base (INT (10), INT (20)),
- value_range_base (INT (25), INT (70))));
+ ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)),
+ value_range (INT (25), INT (70))));
- if (value_range_base::m_max_pairs > 2)
+ if (value_range::m_max_pairs > 2)
{
// [10,20][30,40][50,60] U [15,35] => [10,40][50,60].
r0 = RANGE3 (10, 20, 30, 40, 50, 60);
- r1 = value_range_base (INT (15), INT (35));
+ r1 = value_range (INT (15), INT (35));
r0.union_ (r1);
- ASSERT_TRUE (r0 == range_union (value_range_base (INT (10), INT (40)),
- value_range_base (INT (50), INT (60))));
+ ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (40)),
+ value_range (INT (50), INT (60))));
}
// [10,20] U [15, 30] => [10, 30].
- r0 = value_range_base (INT (10), INT (20));
- r1 = value_range_base (INT (15), INT (30));
+ r0 = value_range (INT (10), INT (20));
+ r1 = value_range (INT (15), INT (30));
r0.union_ (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (10), INT (30)));
+ ASSERT_TRUE (r0 == value_range (INT (10), INT (30)));
// [10,20] U [25,25] => [10,20][25,25].
- r0 = value_range_base (INT (10), INT (20));
- r1 = value_range_base (INT (25), INT (25));
+ r0 = value_range (INT (10), INT (20));
+ r1 = value_range (INT (25), INT (25));
r0.union_ (r1);
- ASSERT_TRUE (r0 == range_union (value_range_base (INT (10), INT (20)),
- value_range_base (INT (25), INT (25))));
+ ASSERT_TRUE (r0 == range_union (value_range (INT (10), INT (20)),
+ value_range (INT (25), INT (25))));
- if (value_range_base::m_max_pairs > 2)
+ if (value_range::m_max_pairs > 2)
{
// [10,20][30,40][50,60] U [35,35] => [10,20][30,40][50,60].
r0 = RANGE3 (10, 20, 30, 40, 50, 60);
- r1 = value_range_base (INT (35), INT (35));
+ r1 = value_range (INT (35), INT (35));
r0.union_ (r1);
ASSERT_TRUE (r0 == RANGE3 (10, 20, 30, 40, 50, 60));
}
// [15,40] U [] => [15,40].
- r0 = value_range_base (INT (15), INT (40));
+ r0 = value_range (INT (15), INT (40));
r1.set_undefined ();
r0.union_ (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (15), INT (40)));
+ ASSERT_TRUE (r0 == value_range (INT (15), INT (40)));
// [10,20] U [10,10] => [10,20].
- r0 = value_range_base (INT (10), INT (20));
- r1 = value_range_base (INT (10), INT (10));
+ r0 = value_range (INT (10), INT (20));
+ r1 = value_range (INT (10), INT (10));
r0.union_ (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (10), INT (20)));
+ ASSERT_TRUE (r0 == value_range (INT (10), INT (20)));
// [10,20] U [9,9] => [9,20].
- r0 = value_range_base (INT (10), INT (20));
- r1 = value_range_base (INT (9), INT (9));
+ r0 = value_range (INT (10), INT (20));
+ r1 = value_range (INT (9), INT (9));
r0.union_ (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (9), INT (20)));
+ ASSERT_TRUE (r0 == value_range (INT (9), INT (20)));
- if (value_range_base::m_max_pairs > 2)
+ if (value_range::m_max_pairs > 2)
{
// [10,10][12,12][20,100] ^ [15,200].
r0 = RANGE3 (10, 10, 12, 12, 20, 100);
- r1 = value_range_base (INT (15), INT (200));
+ r1 = value_range (INT (15), INT (200));
r0.intersect (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (20), INT (100)));
+ ASSERT_TRUE (r0 == value_range (INT (20), INT (100)));
// [10,20][30,40][50,60] ^ [15,25][38,51][55,70]
// => [15,20][38,40][50,51][55,60]
r0 = RANGE3 (10, 20, 30, 40, 50, 60);
r1 = RANGE3 (15, 25, 38, 51, 55, 70);
r0.intersect (r1);
- if (value_range_base::m_max_pairs == 3)
+ if (value_range::m_max_pairs == 3)
{
// When pairs==3, we don't have enough space, so
// conservatively handle things. Thus, the ...[50,60].
@@ -3200,7 +3188,7 @@ range_tests ()
else
{
r2 = RANGE3 (15, 20, 38, 40, 50, 51);
- r2.union_ (value_range_base (INT (55), INT (60)));
+ r2.union_ (value_range (INT (55), INT (60)));
ASSERT_TRUE (r0 == r2);
}
@@ -3209,7 +3197,7 @@ range_tests ()
r0 = RANGE3 (15, 20, 30, 40, 50, 60);
r1 = RANGE3 (15, 35, 40, 90, 100, 200);
r0.intersect (r1);
- if (value_range_base::m_max_pairs == 3)
+ if (value_range::m_max_pairs == 3)
{
// When pairs==3, we don't have enough space, so
// conservatively handle things.
@@ -3218,7 +3206,7 @@ range_tests ()
else
{
r2 = RANGE3 (15, 20, 30, 35, 40, 40);
- r2.union_ (value_range_base (INT (50), INT (60)));
+ r2.union_ (value_range (INT (50), INT (60)));
ASSERT_TRUE (r0 == r2);
}
@@ -3226,29 +3214,29 @@ range_tests ()
// range.
//
// [8,10][135,255] U [14,14] => [8,10][14,14][135,255]
- r0 = range_union (value_range_base (INT (8), INT (10)),
- value_range_base (INT (135), INT (255)));
- r1 = value_range_base (INT (14), INT (14));
+ r0 = range_union (value_range (INT (8), INT (10)),
+ value_range (INT (135), INT (255)));
+ r1 = value_range (INT (14), INT (14));
r0.union_ (r1);
ASSERT_TRUE (r0 == RANGE3 (8, 10, 14, 14, 135, 255));
}
// [10,20] ^ [15,30] => [15,20].
- r0 = value_range_base (INT (10), INT (20));
- r1 = value_range_base (INT (15), INT (30));
+ r0 = value_range (INT (10), INT (20));
+ r1 = value_range (INT (15), INT (30));
r0.intersect (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (15), INT (20)));
+ ASSERT_TRUE (r0 == value_range (INT (15), INT (20)));
// [10,20][30,40] ^ [40,50] => [40,40].
- r0 = range_union (value_range_base (INT (10), INT (20)),
- value_range_base (INT (30), INT (40)));
- r1 = value_range_base (INT (40), INT (50));
+ r0 = range_union (value_range (INT (10), INT (20)),
+ value_range (INT (30), INT (40)));
+ r1 = value_range (INT (40), INT (50));
r0.intersect (r1);
- ASSERT_TRUE (r0 == value_range_base (INT (40), INT (40)));
+ ASSERT_TRUE (r0 == value_range (INT (40), INT (40)));
// Test non-destructive intersection.
- r0 = rold = value_range_base (INT (10), INT (20));
- ASSERT_FALSE (range_intersect (r0, value_range_base (INT (15),
+ r0 = rold = value_range (INT (10), INT (20));
+ ASSERT_FALSE (range_intersect (r0, value_range (INT (15),
INT (30))).undefined_p ());
ASSERT_TRUE (r0 == rold);
@@ -3258,11 +3246,11 @@ range_tests ()
== wi::uhwi (1, TYPE_PRECISION (boolean_type_node)));
// Test zero_p().
- r0 = value_range_base (INT (0), INT (0));
+ r0 = value_range (INT (0), INT (0));
ASSERT_TRUE (r0.zero_p ());
// Test nonzero_p().
- r0 = value_range_base (INT (0), INT (0));
+ r0 = value_range (INT (0), INT (0));
r0.invert ();
ASSERT_TRUE (r0.nonzero_p ());
}
diff --git a/gcc/range-op.h b/gcc/range-op.h
index e531b91..3df9f1d 100644
--- a/gcc/range-op.h
+++ b/gcc/range-op.h
@@ -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,
diff --git a/gcc/range.cc b/gcc/range.cc
index 5e4d904..8e5c979 100644
--- a/gcc/range.cc
+++ b/gcc/range.cc
@@ -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;
}
diff --git a/gcc/range.h b/gcc/range.h
index 3983171..b4806e6 100644
--- a/gcc/range.h
+++ b/gcc/range.h
@@ -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
diff --git a/gcc/selftest.h b/gcc/selftest.h
index 6f2c2af..933c0aa 100644
--- a/gcc/selftest.h
+++ b/gcc/selftest.h
@@ -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. */
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index bcb5cf4..44a4289 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -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;
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index 50cc442..163be2d 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -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
diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c
index 1776a6d..a5d8766 100644
--- a/gcc/tree-ssa-threadedge.c
+++ b/gcc/tree-ssa-threadedge.c
@@ -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:
diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index f7b638d..ac92ae4 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -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;
diff --git a/gcc/tree-ssanames.h b/gcc/tree-ssanames.h
index 1a7d0bc..04c07c2 100644
--- a/gcc/tree-ssanames.h
+++ b/gcc/tree-ssanames.h
@@ -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);
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index e1d5c7c..1328707 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -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,13 +488,13 @@ 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 *vr)
+dump_value_range (FILE *file, const value_range_equiv *vr)
{
if (!vr)
fprintf (file, "[]");
@@ -502,7 +503,7 @@ dump_value_range (FILE *file, const value_range *vr)
}
void
-dump_value_range (FILE *file, const value_range_base *vr)
+dump_value_range (FILE *file, const value_range *vr)
{
if (!vr)
fprintf (file, "[]");
@@ -511,25 +512,25 @@ dump_value_range (FILE *file, const value_range_base *vr)
}
DEBUG_FUNCTION void
-debug (const value_range_base *vr)
+debug (const value_range *vr)
{
dump_value_range (stderr, vr);
}
DEBUG_FUNCTION void
-debug (const value_range_base &vr)
+debug (const value_range &vr)
{
dump_value_range (stderr, &vr);
}
DEBUG_FUNCTION void
-debug (const value_range *vr)
+debug (const value_range_equiv *vr)
{
dump_value_range (stderr, vr);
}
DEBUG_FUNCTION void
-debug (const value_range &vr)
+debug (const value_range_equiv &vr)
{
dump_value_range (stderr, &vr);
}
@@ -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 ())
{
diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h
index 0bf33ca..ff01c2a 100644
--- a/gcc/tree-vrp.h
+++ b/gcc/tree-vrp.h
@@ -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;
diff --git a/gcc/vr-values.c b/gcc/vr-values.c
index d1713bf..b970339 100644
--- a/gcc/vr-values.c
+++ b/gcc/vr-values.c
@@ -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;
diff --git a/gcc/vr-values.h b/gcc/vr-values.h
index ec65de3..0bba477 100644
--- a/gcc/vr-values.h
+++ b/gcc/vr-values.h
@@ -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