Commit 0982acbe by Richard Biener Committed by Richard Biener

gimple-loop-versioning.cc (loop_versioning::prune_loop_conditions): Make…

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
parent 6343b6bf
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>
......
......@@ -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 ())
......
......@@ -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;
}
......@@ -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;
......
......@@ -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);
......
......@@ -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 ());
......
......@@ -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 ())
......
......@@ -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)
{
......
......@@ -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 *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment