aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2023-07-04 11:28:52 -0400
committerAndrew MacLeod <amacleod@redhat.com>2023-07-05 19:06:30 -0400
commit70d1e3f40f09102c6b12c58d97809552b1a08961 (patch)
tree0eae3ce00c34edd1496fffbe2930eb33ba5dbe6c
parentacfe8fa8dc4907e8fe7b878654112c397d6d59c3 (diff)
downloadgcc-70d1e3f40f09102c6b12c58d97809552b1a08961.zip
gcc-70d1e3f40f09102c6b12c58d97809552b1a08961.tar.gz
gcc-70d1e3f40f09102c6b12c58d97809552b1a08961.tar.bz2
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.
-rw-r--r--gcc/gimple-range-gori.cc42
1 files changed, 13 insertions, 29 deletions
diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index 4ee0ae3..b0d13a8 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -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);