gimple-loop-versioning.cc (loop_versioning::prune_loop_conditions): Make value_range * temporary const.

2019-07-25  Richard Biener  <rguenther@suse.de>

	* gimple-loop-versioning.cc (loop_versioning::prune_loop_conditions):
	Make value_range * temporary const.
	* gimple-ssa-evrp-analyze.c (evrp_range_analyzer::try_find_new_range):
	Likewise.
	(evrp_range_analyzer::record_ranges_from_): Likewise.
	(evrp_range_analyzer::pop_value_range): Return a const value_range *,
	deal with having recorded a const one.
	* gimple-ssa-evrp-analyze.h (evrp_range_analyzer::get_value_range):
	Return a const value_range *.
	(evrp_range_analyzer::pop_value_range): Likewise.
	(evrp_range_analyzer::stack): Record const value_range *s.
	* gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children):
	Adjust.
	* gimple-ssa-sprintf.c (get_int_range): Likewise.
	(format_integer): Likewise.
	(sprintf_dom_walker::handle_gimple_call): Likewise.
	* tree-ssa-dom.c (simplify_stmt_for_jump_threading): Likewise.
	* tree-vrp.c (vrp_prop::set_def_to_varying): Add.
	(vrp_prop::get_value_range): Adjust.
	(vrp_prop::vrp_initialize): Use set_def_to_varying instead of
	modifying the lattice in-place.
	(vrp_prop::visit_stmt): Likewise.
	* vr-values.c (vr_values::get_lattice_entry): New private method.
	(vr_values::get_value_range): Wrap it and return a const
	value_range *.
	(vr_values::set_def_to_varying): New.
	(vr_values::set_defs_to_varying): Use it.
	(vr_values::update_value_range): Likewise.
	(vr_values::vrp_stmt_computes_nonzero): Adjust.
	(values::op_with_constant_singleton_va): Likewise.
	(vr_values::extract_range_for_var_from_co): Likewise.
	(vr_values::extract_range_from_ssa_name): Likewise.
	(vr_values::extract_range_from_cond_expr): Likewise.
	(vr_values::extract_range_basic): Likewise.
	(compare_ranges): Take const value_range *, adjust.
	(compare_range_with_value): Likewise.
	(vrp_valueize): Adjust.
	(vrp_valueize_1): Likewise.
	(vr_values::get_vr_for_comparison): Return a const value_range *.
	(vr_values::compare_name_with_value): Adjust.
	(vr_values::compare_names): Likewise.
	(vr_values::vrp_evaluate_conditional_warnv_with_ops_using_ranges):
	Likewise.
	(vr_values::vrp_evaluate_conditional): Likewise.
	(find_case_label_ranges): Take a const value_range *.
	(vr_values::vrp_visit_switch_stmt): Adjust.
	(vr_values::extract_range_from_phi_node): Likewise.
	(vr_values::simplify_div_or_mod_using_ran): Likewise.
	(vr_values::simplify_abs_using_ranges): Likewise.
	(test_for_singularity): Take a const value_range *.
	(range_fits_type_p): Likewise.
	(vr_values::simplify_cond_using_ranges_1): Adjust.
	(vr_values::simplify_cond_using_ranges_2): Likewise.
	(vr_values::simplify_switch_using_ranges): Likewise.
	(vr_values::simplify_float_conversion_usi): Likewise.
	(vr_values::two_valued_val_range_p): Likewise.
	* vr-values.h (vr_values::get_value_range): Return a const
	value_range *.
	(vr_values::set_def_to_varying): New.
	(vr_values::get_lattice_entry): New private method.
	(vr_values::get_vr_for_comparison): Return a const value_range *.

From-SVN: r273792
This commit is contained in:
Richard Biener 2019-07-25 10:25:13 +00:00 committed by Richard Biener
parent 6343b6bf3b
commit 0982acbe28
10 changed files with 174 additions and 87 deletions

View file

@ -1,3 +1,67 @@
2019-07-25 Richard Biener <rguenther@suse.de>
* gimple-loop-versioning.cc (loop_versioning::prune_loop_conditions):
Make value_range * temporary const.
* gimple-ssa-evrp-analyze.c (evrp_range_analyzer::try_find_new_range):
Likewise.
(evrp_range_analyzer::record_ranges_from_): Likewise.
(evrp_range_analyzer::pop_value_range): Return a const value_range *,
deal with having recorded a const one.
* gimple-ssa-evrp-analyze.h (evrp_range_analyzer::get_value_range):
Return a const value_range *.
(evrp_range_analyzer::pop_value_range): Likewise.
(evrp_range_analyzer::stack): Record const value_range *s.
* gimple-ssa-evrp.c (evrp_dom_walker::before_dom_children):
Adjust.
* gimple-ssa-sprintf.c (get_int_range): Likewise.
(format_integer): Likewise.
(sprintf_dom_walker::handle_gimple_call): Likewise.
* tree-ssa-dom.c (simplify_stmt_for_jump_threading): Likewise.
* tree-vrp.c (vrp_prop::set_def_to_varying): Add.
(vrp_prop::get_value_range): Adjust.
(vrp_prop::vrp_initialize): Use set_def_to_varying instead of
modifying the lattice in-place.
(vrp_prop::visit_stmt): Likewise.
* vr-values.c (vr_values::get_lattice_entry): New private method.
(vr_values::get_value_range): Wrap it and return a const
value_range *.
(vr_values::set_def_to_varying): New.
(vr_values::set_defs_to_varying): Use it.
(vr_values::update_value_range): Likewise.
(vr_values::vrp_stmt_computes_nonzero): Adjust.
(values::op_with_constant_singleton_va): Likewise.
(vr_values::extract_range_for_var_from_co): Likewise.
(vr_values::extract_range_from_ssa_name): Likewise.
(vr_values::extract_range_from_cond_expr): Likewise.
(vr_values::extract_range_basic): Likewise.
(compare_ranges): Take const value_range *, adjust.
(compare_range_with_value): Likewise.
(vrp_valueize): Adjust.
(vrp_valueize_1): Likewise.
(vr_values::get_vr_for_comparison): Return a const value_range *.
(vr_values::compare_name_with_value): Adjust.
(vr_values::compare_names): Likewise.
(vr_values::vrp_evaluate_conditional_warnv_with_ops_using_ranges):
Likewise.
(vr_values::vrp_evaluate_conditional): Likewise.
(find_case_label_ranges): Take a const value_range *.
(vr_values::vrp_visit_switch_stmt): Adjust.
(vr_values::extract_range_from_phi_node): Likewise.
(vr_values::simplify_div_or_mod_using_ran): Likewise.
(vr_values::simplify_abs_using_ranges): Likewise.
(test_for_singularity): Take a const value_range *.
(range_fits_type_p): Likewise.
(vr_values::simplify_cond_using_ranges_1): Adjust.
(vr_values::simplify_cond_using_ranges_2): Likewise.
(vr_values::simplify_switch_using_ranges): Likewise.
(vr_values::simplify_float_conversion_usi): Likewise.
(vr_values::two_valued_val_range_p): Likewise.
* vr-values.h (vr_values::get_value_range): Return a const
value_range *.
(vr_values::set_def_to_varying): New.
(vr_values::get_lattice_entry): New private method.
(vr_values::get_vr_for_comparison): Return a const value_range *.
2019-07-25 Martin Liska <mliska@suse.cz>
Dominik Infuhr <dominik.infuehr@theobroma-systems.com>

View file

@ -1489,7 +1489,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);
value_range *vr = vrs->get_value_range (name);
const value_range *vr = vrs->get_value_range (name);
if (vr && !vr->may_contain_p (build_one_cst (TREE_TYPE (name))))
{
if (dump_enabled_p ())

View file

@ -84,7 +84,7 @@ evrp_range_analyzer::try_find_new_range (tree name,
tree op, tree_code code, tree limit)
{
value_range vr;
value_range *old_vr = get_value_range (name);
const value_range *old_vr = get_value_range (name);
/* Discover VR when condition is true. */
vr_values->extract_range_for_var_from_comparison_expr (name, code, op,
@ -209,7 +209,7 @@ 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). */
value_range *old_vr = get_value_range (vrs[i].first);
const value_range *old_vr = get_value_range (vrs[i].first);
value_range_base tem (old_vr->kind (), old_vr->min (),
old_vr->max ());
tem.intersect (vrs[i].second);
@ -427,10 +427,10 @@ evrp_range_analyzer::push_value_range (tree var, value_range *vr)
/* Pop the Value Range from the vrp_stack and update VAR with it. */
value_range *
const value_range *
evrp_range_analyzer::pop_value_range (tree var)
{
value_range *vr = stack.last ().second;
const value_range *vr = stack.last ().second;
gcc_checking_assert (var == stack.last ().first);
if (dump_file && (dump_flags & TDF_DETAILS))
{
@ -440,7 +440,9 @@ evrp_range_analyzer::pop_value_range (tree var)
dump_value_range (dump_file, vr);
fprintf (dump_file, "\n");
}
vr_values->set_vr_value (var, vr);
/* We saved off a lattice entry, now give it back - it can now
be modified again, thus the const casting. */
vr_values->set_vr_value (var, const_cast <value_range *> (vr));
stack.pop ();
return vr;
}

View file

@ -37,7 +37,7 @@ class evrp_range_analyzer
void record_ranges_from_stmt (gimple *, bool);
/* Main interface to retrieve range information. */
value_range *get_value_range (const_tree op)
const value_range *get_value_range (const_tree op)
{ return vr_values->get_value_range (op); }
/* Record a new unwindable range. */
@ -62,14 +62,14 @@ class evrp_range_analyzer
DISABLE_COPY_AND_ASSIGN (evrp_range_analyzer);
class vr_values *vr_values;
value_range *pop_value_range (tree var);
const value_range *pop_value_range (tree var);
value_range *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 *);
/* STACK holds the old VR. */
auto_vec<std::pair <tree, value_range*> > stack;
auto_vec<std::pair <tree, const value_range*> > stack;
/* True if we are updating global ranges, false otherwise. */
bool m_update_global_ranges;

View file

@ -109,7 +109,7 @@ evrp_dom_walker::before_dom_children (basic_block bb)
if (virtual_operand_p (lhs))
continue;
value_range *vr = evrp_range_analyzer.get_value_range (lhs);
const value_range *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))
@ -159,7 +159,8 @@ evrp_dom_walker::before_dom_children (basic_block bb)
if (output)
{
tree val;
value_range *vr = evrp_range_analyzer.get_value_range (output);
const value_range *vr
= evrp_range_analyzer.get_value_range (output);
/* Mark stmts whose output we fully propagate for removal. */
if (vr->singleton_p (&val)
@ -243,7 +244,7 @@ evrp_dom_walker::before_dom_children (basic_block bb)
if (TREE_CODE (arg) != SSA_NAME
|| virtual_operand_p (arg))
continue;
value_range *vr = evrp_range_analyzer.get_value_range (arg);
const value_range *vr = evrp_range_analyzer.get_value_range (arg);
tree val;
if (vr->singleton_p (&val) && may_propagate_copy (arg, val))
propagate_value (use_p, val);

View file

@ -1086,7 +1086,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. */
value_range *vr = vr_values->get_value_range (arg);
const value_range *vr = vr_values->get_value_range (arg);
if (range_int_cst_p (vr))
{
HOST_WIDE_INT type_min
@ -1386,7 +1386,7 @@ format_integer (const directive &dir, tree arg, vr_values *vr_values)
{
/* Try to determine the range of values of the integer argument
(range information is not available for pointers). */
value_range *vr = vr_values->get_value_range (arg);
const value_range *vr = vr_values->get_value_range (arg);
if (range_int_cst_p (vr))
{
argmin = vr->min ();
@ -4119,7 +4119,7 @@ sprintf_dom_walker::handle_gimple_call (gimple_stmt_iterator *gsi)
/* 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. */
value_range *vr = evrp_range_analyzer.get_value_range (size);
const value_range *vr = evrp_range_analyzer.get_value_range (size);
if (range_int_cst_p (vr))
{
unsigned HOST_WIDE_INT minsize = TREE_INT_CST_LOW (vr->min ());

View file

@ -901,7 +901,7 @@ simplify_stmt_for_jump_threading (gimple *stmt,
if (TREE_CODE (op) != SSA_NAME)
return NULL_TREE;
value_range *vr = x_vr_values->get_value_range (op);
const value_range *vr = x_vr_values->get_value_range (op);
if (vr->undefined_p ()
|| vr->varying_p ()
|| vr->symbolic_p ())

View file

@ -4292,10 +4292,12 @@ class vrp_prop : public ssa_propagation_engine
class vr_values vr_values;
/* Temporary delegator to minimize code churn. */
value_range *get_value_range (const_tree op)
const value_range *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)
{ return vr_values.set_defs_to_varying (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)
{ vr_values.extract_range_from_stmt (stmt, taken_edge_p, output_p, vr); }
@ -5148,7 +5150,7 @@ vrp_prop::vrp_initialize ()
if (!stmt_interesting_for_vrp (phi))
{
tree lhs = PHI_RESULT (phi);
get_value_range (lhs)->set_varying ();
set_def_to_varying (lhs);
prop_set_simulate_again (phi, false);
}
else
@ -5343,7 +5345,7 @@ vrp_prop::visit_stmt (gimple *stmt, edge *taken_edge_p, tree *output_p)
use_operand_p use_p;
enum ssa_prop_result res = SSA_PROP_VARYING;
get_value_range (lhs)->set_varying ();
set_def_to_varying (lhs);
FOR_EACH_IMM_USE_FAST (use_p, iter, lhs)
{

View file

@ -69,29 +69,21 @@ set_value_range_to_truthvalue (value_range *vr, tree type)
vr->update (VR_RANGE, build_int_cst (type, 0), build_int_cst (type, 1));
}
/* Return value range information for 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. */
/* Return the lattice entry for VAR or NULL if it doesn't exist or cannot
be initialized. */
value_range *
vr_values::get_value_range (const_tree var)
vr_values::get_lattice_entry (const_tree var)
{
static const value_range vr_const_varying (VR_VARYING, NULL, NULL);
value_range *vr;
tree sym;
unsigned ver = SSA_NAME_VERSION (var);
/* If we have no recorded ranges, then return NULL. */
if (! vr_value)
return NULL;
/* If we query the range for a new SSA name return an unmodifiable VARYING.
We should get here at most from the substitute-and-fold stage which
/* If we query the entry for a new SSA name avoid reallocating the lattice
since we should get here at most from the substitute-and-fold stage which
will never try to change values. */
if (ver >= num_vr_values)
return CONST_CAST (value_range *, &vr_const_varying);
return NULL;
vr = vr_value[ver];
if (vr)
@ -99,7 +91,7 @@ vr_values::get_value_range (const_tree var)
/* After propagation finished do not allocate new value-ranges. */
if (values_propagated)
return CONST_CAST (value_range *, &vr_const_varying);
return NULL;
/* Create a default value range. */
vr_value[ver] = vr = vrp_value_range_pool.allocate ();
@ -142,6 +134,37 @@ vr_values::get_value_range (const_tree var)
return vr;
}
/* Return value range information for 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 *
vr_values::get_value_range (const_tree var)
{
static const value_range vr_const_varying (VR_VARYING, NULL, NULL);
/* If we have no recorded ranges, then return NULL. */
if (!vr_value)
return NULL;
value_range *vr = get_lattice_entry (var);
if (!vr)
return &vr_const_varying;
return vr;
}
/* Set the lattice entry for DEF to VARYING. */
void
vr_values::set_def_to_varying (const_tree def)
{
value_range *vr = get_lattice_entry (def);
if (vr)
vr->set_varying ();
}
/* Set value-ranges of all SSA names defined by STMT to varying. */
void
@ -150,12 +173,7 @@ vr_values::set_defs_to_varying (gimple *stmt)
ssa_op_iter i;
tree def;
FOR_EACH_SSA_TREE_OPERAND (def, stmt, i, SSA_OP_DEF)
{
value_range *vr = get_value_range (def);
/* Avoid writing to vr_const_varying get_value_range may return. */
if (!vr->varying_p ())
vr->set_varying ();
}
set_def_to_varying (def);
}
/* Update the value range and equivalence set for variable VAR to
@ -185,7 +203,7 @@ vr_values::update_value_range (const_tree var, value_range *new_vr)
}
/* Update the value range, if necessary. */
old_vr = get_value_range (var);
old_vr = get_lattice_entry (var);
is_new = !old_vr->equal_p (*new_vr, /*ignore_equivs=*/false);
if (is_new)
@ -339,7 +357,7 @@ vr_values::vrp_stmt_computes_nonzero (gimple *stmt)
|| (flag_delete_null_pointer_checks
&& !TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr))))
{
value_range *vr = get_value_range (TREE_OPERAND (base, 0));
const value_range *vr = get_value_range (TREE_OPERAND (base, 0));
if (!range_includes_zero_p (vr))
return true;
}
@ -398,7 +416,7 @@ vr_values::op_with_constant_singleton_value_range (tree op)
bool
vr_values::op_with_boolean_value_range_p (tree op)
{
value_range *vr;
const value_range *vr;
if (TYPE_PRECISION (TREE_TYPE (op)) == 1)
return true;
@ -426,7 +444,7 @@ vr_values::extract_range_for_var_from_comparison_expr (tree var,
value_range *vr_p)
{
tree min, max, type;
value_range *limit_vr;
const value_range *limit_vr;
type = TREE_TYPE (var);
/* For pointer arithmetic, we only keep track of pointer equality
@ -715,7 +733,7 @@ vr_values::extract_range_from_assert (value_range *vr_p, tree expr)
void
vr_values::extract_range_from_ssa_name (value_range *vr, tree var)
{
value_range *var_vr = get_value_range (var);
const value_range *var_vr = get_value_range (var);
if (!var_vr->varying_p ())
vr->deep_copy (var_vr);
@ -907,7 +925,7 @@ vr_values::extract_range_from_cond_expr (value_range *vr, gassign *stmt)
a new value range with the operand to simplify processing. */
tree op0 = gimple_assign_rhs2 (stmt);
value_range tem0;
value_range *vr0 = &tem0;
const value_range *vr0 = &tem0;
if (TREE_CODE (op0) == SSA_NAME)
vr0 = get_value_range (op0);
else if (is_gimple_min_invariant (op0))
@ -917,7 +935,7 @@ vr_values::extract_range_from_cond_expr (value_range *vr, gassign *stmt)
tree op1 = gimple_assign_rhs3 (stmt);
value_range tem1;
value_range *vr1 = &tem1;
const value_range *vr1 = &tem1;
if (TREE_CODE (op1) == SSA_NAME)
vr1 = get_value_range (op1);
else if (is_gimple_min_invariant (op1))
@ -1113,7 +1131,7 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
maxi = prec;
if (TREE_CODE (arg) == SSA_NAME)
{
value_range *vr0 = get_value_range (arg);
const value_range *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;
@ -1151,7 +1169,7 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
mini = -2;
if (TREE_CODE (arg) == SSA_NAME)
{
value_range *vr0 = get_value_range (arg);
const value_range *vr0 = get_value_range (arg);
/* From clz of VR_RANGE minimum we can compute
result maximum. */
if (vr0->kind () == VR_RANGE
@ -1208,7 +1226,7 @@ vr_values::extract_range_basic (value_range *vr, gimple *stmt)
}
if (TREE_CODE (arg) == SSA_NAME)
{
value_range *vr0 = get_value_range (arg);
const value_range *vr0 = get_value_range (arg);
/* If arg is non-zero, then use [0, prec - 1]. */
if ((vr0->kind () == VR_RANGE
&& integer_nonzerop (vr0->min ()))
@ -1468,8 +1486,8 @@ vr_values::extract_range_from_assignment (value_range *vr, gassign *stmt)
static tree
compare_ranges (enum tree_code comp, value_range *vr0, value_range *vr1,
bool *strict_overflow_p)
compare_ranges (enum tree_code comp, const value_range *vr0,
const value_range *vr1, bool *strict_overflow_p)
{
/* VARYING or UNDEFINED ranges cannot be compared. */
if (vr0->varying_p ()
@ -1496,12 +1514,8 @@ compare_ranges (enum tree_code comp, value_range *vr0, value_range *vr1,
/* Equality can be computed only between a range and an
anti-range. ~[VAL1, VAL2] == [VAL1, VAL2] is always false. */
if (vr0->kind () == VR_RANGE)
{
/* To simplify processing, make VR0 the anti-range. */
value_range *tmp = vr0;
vr0 = vr1;
vr1 = tmp;
}
/* To simplify processing, make VR0 the anti-range. */
std::swap (vr0, vr1);
gcc_assert (comp == NE_EXPR || comp == EQ_EXPR);
@ -1607,7 +1621,7 @@ compare_ranges (enum tree_code comp, value_range *vr0, value_range *vr1,
assumed signed overflow is undefined. */
static tree
compare_range_with_value (enum tree_code comp, value_range *vr, tree val,
compare_range_with_value (enum tree_code comp, const value_range *vr, tree val,
bool *strict_overflow_p)
{
if (vr->varying_p () || vr->undefined_p ())
@ -1961,7 +1975,7 @@ vrp_valueize (tree name)
{
if (TREE_CODE (name) == SSA_NAME)
{
value_range *vr = x_vr_values->get_value_range (name);
const value_range *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 ()))
@ -1986,7 +2000,7 @@ vrp_valueize_1 (tree name)
if (!gimple_nop_p (def_stmt)
&& prop_simulate_again_p (def_stmt))
return NULL_TREE;
value_range *vr = x_vr_values->get_value_range (name);
const value_range *vr = x_vr_values->get_value_range (name);
tree singleton;
if (vr->singleton_p (&singleton))
return singleton;
@ -2064,11 +2078,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. */
value_range *
const value_range *
vr_values::get_vr_for_comparison (int i, value_range *tem)
{
/* Shallow-copy equiv bitmap. */
value_range *vr = get_value_range (ssa_name (i));
const value_range *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
@ -2097,7 +2111,8 @@ vr_values::compare_name_with_value (enum tree_code comp, tree var, tree val,
tree retval, t;
int used_strict_overflow;
bool sop;
value_range *equiv_vr, tem_vr;
const value_range *equiv_vr;
value_range tem_vr;
/* Get the set of equivalences for VAR. */
e = get_value_range (var)->equiv ();
@ -2233,7 +2248,7 @@ vr_values::compare_names (enum tree_code comp, tree n1, tree n2,
continue;
value_range tem_vr1;
value_range *vr1 = get_vr_for_comparison (i1, &tem_vr1);
const value_range *vr1 = get_vr_for_comparison (i1, &tem_vr1);
t = retval = NULL_TREE;
EXECUTE_IF_SET_IN_BITMAP (e2, 0, i2, bi2)
@ -2244,7 +2259,7 @@ vr_values::compare_names (enum tree_code comp, tree n1, tree n2,
bool sop = false;
value_range tem_vr2;
value_range *vr2 = get_vr_for_comparison (i2, &tem_vr2);
const value_range *vr2 = get_vr_for_comparison (i2, &tem_vr2);
t = compare_ranges (comp, vr1, vr2, &sop);
if (t)
@ -2293,7 +2308,7 @@ tree
vr_values::vrp_evaluate_conditional_warnv_with_ops_using_ranges
(enum tree_code code, tree op0, tree op1, bool * strict_overflow_p)
{
value_range *vr0, *vr1;
const value_range *vr0, *vr1;
vr0 = (TREE_CODE (op0) == SSA_NAME) ? get_value_range (op0) : NULL;
vr1 = (TREE_CODE (op1) == SSA_NAME) ? get_value_range (op1) : NULL;
@ -2373,7 +2388,7 @@ vr_values::vrp_evaluate_conditional_warnv_with_ops (enum tree_code code,
}
else
gcc_unreachable ();
value_range *vr0 = get_value_range (op0);
const value_range *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.
@ -2479,7 +2494,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);
value_range *vr0 = get_value_range (op0);
const value_range *vr0 = get_value_range (op0);
if (vr0->kind () == VR_RANGE
&& INTEGRAL_TYPE_P (type)
@ -2605,7 +2620,7 @@ 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, value_range *vr, size_t *min_idx1,
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)
{
@ -2685,7 +2700,7 @@ void
vr_values::vrp_visit_switch_stmt (gswitch *stmt, edge *taken_edge_p)
{
tree op, val;
value_range *vr;
const value_range *vr;
size_t i = 0, j = 0, k, l;
bool take_default;
@ -2803,7 +2818,7 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
{
size_t i;
tree lhs = PHI_RESULT (phi);
value_range *lhs_vr = get_value_range (lhs);
const value_range *lhs_vr = get_value_range (lhs);
bool first = true;
int edges, old_edges;
class loop *l;
@ -2832,7 +2847,7 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
{
tree arg = PHI_ARG_DEF (phi, i);
value_range vr_arg_tem;
value_range *vr_arg = &vr_arg_tem;
const value_range *vr_arg = &vr_arg_tem;
++edges;
@ -2845,7 +2860,7 @@ vr_values::extract_range_from_phi_node (gphi *phi, value_range *vr_result)
&& e->flags & EDGE_DFS_BACK)
may_simulate_backedge_again = true;
value_range *vr_arg_ = get_value_range (arg);
const value_range *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. */
@ -3096,7 +3111,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;
value_range *vr = NULL;
const value_range *vr = NULL;
if (TREE_CODE (op0) == INTEGER_CST)
{
@ -3116,7 +3131,7 @@ vr_values::simplify_div_or_mod_using_ranges (gimple_stmt_iterator *gsi,
if (rhs_code == TRUNC_MOD_EXPR
&& TREE_CODE (op1) == SSA_NAME)
{
value_range *vr1 = get_value_range (op1);
const value_range *vr1 = get_value_range (op1);
if (range_int_cst_p (vr1))
op1min = vr1->min ();
}
@ -3263,7 +3278,7 @@ bool
vr_values::simplify_abs_using_ranges (gimple_stmt_iterator *gsi, gimple *stmt)
{
tree op = gimple_assign_rhs1 (stmt);
value_range *vr = get_value_range (op);
const value_range *vr = get_value_range (op);
if (vr)
{
@ -3401,7 +3416,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, value_range *vr)
tree op1, const value_range *vr)
{
tree min = NULL;
tree max = NULL;
@ -3459,7 +3474,8 @@ test_for_singularity (enum tree_code cond_code, tree op0,
by PRECISION and UNSIGNED_P. */
static bool
range_fits_type_p (value_range *vr, unsigned dest_precision, signop dest_sgn)
range_fits_type_p (const value_range *vr,
unsigned dest_precision, signop dest_sgn)
{
tree src_type;
unsigned src_precision;
@ -3523,7 +3539,7 @@ vr_values::simplify_cond_using_ranges_1 (gcond *stmt)
&& INTEGRAL_TYPE_P (TREE_TYPE (op0))
&& is_gimple_min_invariant (op1))
{
value_range *vr = get_value_range (op0);
const value_range *vr = get_value_range (op0);
/* If we have range information for OP0, then we might be
able to simplify this conditional. */
@ -3626,7 +3642,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)))
{
value_range *vr = get_value_range (innerop);
const value_range *vr = get_value_range (innerop);
if (range_int_cst_p (vr)
&& range_fits_type_p (vr,
@ -3656,7 +3672,7 @@ bool
vr_values::simplify_switch_using_ranges (gswitch *stmt)
{
tree op = gimple_switch_index (stmt);
value_range *vr = NULL;
const value_range *vr = NULL;
bool take_default;
edge e;
edge_iterator ei;
@ -3956,7 +3972,7 @@ vr_values::simplify_float_conversion_using_ranges (gimple_stmt_iterator *gsi,
gimple *stmt)
{
tree rhs1 = gimple_assign_rhs1 (stmt);
value_range *vr = get_value_range (rhs1);
const value_range *vr = get_value_range (rhs1);
scalar_float_mode fltmode
= SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (gimple_assign_lhs (stmt)));
scalar_int_mode mode;
@ -4119,7 +4135,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)
{
value_range *vr = get_value_range (var);
const value_range *vr = get_value_range (var);
if (vr->varying_p ()
|| vr->undefined_p ()
|| TREE_CODE (vr->min ()) != INTEGER_CST

View file

@ -40,9 +40,10 @@ class vr_values
vr_values (void);
~vr_values (void);
value_range *get_value_range (const_tree);
const value_range *get_value_range (const_tree);
void set_vr_value (tree, value_range *);
void set_def_to_varying (const_tree);
void set_defs_to_varying (gimple *);
bool update_value_range (const_tree, value_range *);
tree op_with_constant_singleton_value_range (tree);
@ -72,10 +73,11 @@ class vr_values
void cleanup_edges_and_switches (void);
private:
value_range *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 *);
value_range *get_vr_for_comparison (int, value_range *);
const value_range *get_vr_for_comparison (int, value_range *);
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 *);