From 290798faef706c335bd346b13771f977ddedb415 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Tue, 4 Jul 2023 11:28:52 -0400
Subject: [PATCH 1/6] Move relation discovery into compute_operand_range
compute_operand1_range and compute_operand2_range were both doing
relation discovery between the 2 operands... move it into a common area.
* gimple-range-gori.cc (compute_operand_range): Check for
a relation between op1 and op2 and use that instead.
(compute_operand1_range): Don't look for a relation override.
(compute_operand2_range): Ditto.
---
gcc/gimple-range-gori.cc | 42 +++++++++++++---------------------------
1 file changed, 13 insertions(+), 29 deletions(-)
@@ -623,6 +623,18 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt,
tree op1 = gimple_range_ssa_p (handler.operand1 ());
tree op2 = gimple_range_ssa_p (handler.operand2 ());
+ // If there is a relation betwen op1 and op2, use it instead as it is
+ // likely to be more applicable.
+ if (op1 && op2)
+ {
+ relation_kind k = handler.op1_op2_relation (lhs);
+ if (k != VREL_VARYING)
+ {
+ vrel.set_relation (k, op1, op2);
+ vrel_ptr = &vrel;
+ }
+ }
+
// Handle end of lookup first.
if (op1 == name)
return compute_operand1_range (r, handler, lhs, name, src, vrel_ptr);
@@ -1079,7 +1091,6 @@ gori_compute::compute_operand1_range (vrange &r,
const vrange &lhs, tree name,
fur_source &src, value_relation *rel)
{
- value_relation local_rel;
gimple *stmt = handler.stmt ();
tree op1 = handler.operand1 ();
tree op2 = handler.operand2 ();
@@ -1088,7 +1099,6 @@ gori_compute::compute_operand1_range (vrange &r,
relation_trio trio;
if (rel)
trio = rel->create_trio (lhs_name, op1, op2);
- relation_kind op_op = trio.op1_op2 ();
Value_Range op1_range (TREE_TYPE (op1));
Value_Range tmp (TREE_TYPE (op1));
@@ -1102,19 +1112,7 @@ gori_compute::compute_operand1_range (vrange &r,
{
src.get_operand (op2_range, op2);
- // If there is a relation betwen op1 and op2, use it instead.
- // This allows multiple relations to be processed in compound logicals.
- if (gimple_range_ssa_p (op1) && gimple_range_ssa_p (op2))
- {
- relation_kind k = handler.op1_op2_relation (lhs);
- if (k != VREL_VARYING)
- {
- op_op = k;
- local_rel.set_relation (op_op, op1, op2);
- rel = &local_rel;
- }
- }
-
+ relation_kind op_op = trio.op1_op2 ();
if (op_op != VREL_VARYING)
refine_using_relation (op1, op1_range, op2, op2_range, src, op_op);
@@ -1189,7 +1187,6 @@ gori_compute::compute_operand2_range (vrange &r,
const vrange &lhs, tree name,
fur_source &src, value_relation *rel)
{
- value_relation local_rel;
gimple *stmt = handler.stmt ();
tree op1 = handler.operand1 ();
tree op2 = handler.operand2 ();
@@ -1207,19 +1204,6 @@ gori_compute::compute_operand2_range (vrange &r,
trio = rel->create_trio (lhs_name, op1, op2);
relation_kind op_op = trio.op1_op2 ();
- // If there is a relation betwen op1 and op2, use it instead.
- // This allows multiple relations to be processed in compound logicals.
- if (gimple_range_ssa_p (op1) && gimple_range_ssa_p (op2))
- {
- relation_kind k = handler.op1_op2_relation (lhs);
- if (k != VREL_VARYING)
- {
- op_op = k;
- local_rel.set_relation (op_op, op1, op2);
- rel = &local_rel;
- }
- }
-
if (op_op != VREL_VARYING)
refine_using_relation (op1, op1_range, op2, op2_range, src, op_op);
--
2.40.1