Convert some evrp uses in DOM to the range_query API.

DOM is the last remaining user of the evrp engine.  This patch converts
a few uses of the engine and vr-values into the new API.

There is one subtle change.  The call to vr_value's
op_with_constant_singleton_value_range can theoretically return
non-constants, unlike the range_query API which only returns constants.
In this particular case it doesn't matter because the symbolic stuff will
have been handled by the const_and_copies/avail_exprs read in the
SSA_NAME_VALUE copy immediately before.  I have verified this is the case
by asserting that all calls to op_with_constant_singleton_value_range at
this point return either NULL or an INTEGER_CST.

Tested on x86-64 Linux with a regstrap, as well as the aforementioned
assert.

gcc/ChangeLog:

	* gimple-ssa-evrp-analyze.h (class evrp_range_analyzer): Remove
	vrp_visit_cond_stmt.
	* tree-ssa-dom.c (cprop_operand): Convert to range_query API.
	(cprop_into_stmt): Same.
	(dom_opt_dom_walker::optimize_stmt): Same.
This commit is contained in:
Aldy Hernandez 2021-09-25 13:02:21 +02:00
parent 6390c5047a
commit e1d01f4973
2 changed files with 11 additions and 13 deletions

View File

@ -38,13 +38,6 @@ class evrp_range_analyzer : public vr_values
/* Record a new unwindable range. */
void push_value_range (tree var, value_range_equiv *vr);
/* A bit of a wart. This should ideally go away. */
void vrp_visit_cond_stmt (gcond *cond, edge *e)
{
simplify_using_ranges simpl (this);
simpl.vrp_visit_cond_stmt (cond, e);
}
private:
DISABLE_COPY_AND_ASSIGN (evrp_range_analyzer);

View File

@ -1810,7 +1810,7 @@ record_equivalences_from_stmt (gimple *stmt, int may_optimize_p,
CONST_AND_COPIES. */
static void
cprop_operand (gimple *stmt, use_operand_p op_p, vr_values *vr_values)
cprop_operand (gimple *stmt, use_operand_p op_p, range_query *query)
{
tree val;
tree op = USE_FROM_PTR (op_p);
@ -1820,7 +1820,12 @@ cprop_operand (gimple *stmt, use_operand_p op_p, vr_values *vr_values)
CONST_AND_COPIES. */
val = SSA_NAME_VALUE (op);
if (!val)
val = vr_values->op_with_constant_singleton_value_range (op);
{
value_range r;
tree single;
if (query->range_of_expr (r, op, stmt) && r.singleton_p (&single))
val = single;
}
if (val && val != op)
{
@ -1878,7 +1883,7 @@ cprop_operand (gimple *stmt, use_operand_p op_p, vr_values *vr_values)
vdef_ops of STMT. */
static void
cprop_into_stmt (gimple *stmt, vr_values *vr_values)
cprop_into_stmt (gimple *stmt, range_query *query)
{
use_operand_p op_p;
ssa_op_iter iter;
@ -1895,7 +1900,7 @@ cprop_into_stmt (gimple *stmt, vr_values *vr_values)
operands. */
if (old_op != last_copy_propagated_op)
{
cprop_operand (stmt, op_p, vr_values);
cprop_operand (stmt, op_p, query);
tree new_op = USE_FROM_PTR (op_p);
if (new_op != old_op && TREE_CODE (new_op) == SSA_NAME)
@ -2203,8 +2208,8 @@ dom_opt_dom_walker::optimize_stmt (basic_block bb, gimple_stmt_iterator *si,
SSA_NAMES. */
update_stmt_if_modified (stmt);
edge taken_edge = NULL;
m_evrp_range_analyzer->vrp_visit_cond_stmt
(as_a <gcond *> (stmt), &taken_edge);
simplify_using_ranges simpl (m_evrp_range_analyzer);
simpl.vrp_visit_cond_stmt (as_a <gcond *> (stmt), &taken_edge);
if (taken_edge)
{
if (taken_edge->flags & EDGE_TRUE_VALUE)