aboutsummaryrefslogtreecommitdiff
path: root/gcc/value-relation.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2022-10-13 18:03:58 -0400
committerAndrew MacLeod <amacleod@redhat.com>2022-10-17 09:20:39 -0400
commitb565ac19264a5827162d28537bccc8531c25e817 (patch)
tree52a1122cf961dd409f02c3eb5c34811ed5e1f3e7 /gcc/value-relation.cc
parent04874fedae8074b252abbd70fea68bf3dd0a605b (diff)
downloadgcc-b565ac19264a5827162d28537bccc8531c25e817.zip
gcc-b565ac19264a5827162d28537bccc8531c25e817.tar.gz
gcc-b565ac19264a5827162d28537bccc8531c25e817.tar.bz2
Add relation_trio class for range-ops.
There are 3 possible relations range-ops might care about, but only the one most likely to be needed is supplied. This patch provides a new class relation_trio which allows 3 relations to be passed in a single word. fold_range (), op1_range (), and op2_range () are adjusted to take a relation_trio class instead of a relation_kind, then the routine can extract which relation it wants to work with. * gimple-range-fold.cc (fold_using_range::range_of_range_op): Provide relation_trio class. * gimple-range-gori.cc (gori_compute::refine_using_relation): Provide relation_trio class. (gori_compute::refine_using_relation): Ditto. (gori_compute::compute_operand1_range): Provide lhs_op2 and op1_op2 relations via relation_trio class. (gori_compute::compute_operand2_range): Ditto. * gimple-range-op.cc (gimple_range_op_handler::calc_op1): Use relation_trio instead of relation_kind. (gimple_range_op_handler::calc_op2): Ditto. (*::fold_range): Ditto. * gimple-range-op.h (gimple_range_op::calc_op1): Adjust prototypes. (gimple_range_op::calc_op2): Adjust prototypes. * range-op-float.cc (*::fold_range): Use relation_trio instead of relation_kind. (*::op1_range): Ditto. (*::op2_range): Ditto. * range-op.cc (*::fold_range): Use relation_trio instead of relation_kind. (*::op1_range): Ditto. (*::op2_range): Ditto. * range-op.h (class range_operator): Adjust prototypes. (class range_operator_float): Ditto. (class range_op_handler): Adjust prototypes. (relop_early_resolve): Pickup op1_op2 relation from relation_trio. * value-relation.cc (VREL_LAST): Adjust use to be one past the end of the enum. (relation_oracle::validate_relation): Use relation_trio in call to fold_range. * value-relation.h (enum relation_kind_t): Add VREL_LAST as final element. (class relation_trio): New. (TRIO_VARYING, TRIO_SHIFT, TRIO_MASK): New.
Diffstat (limited to 'gcc/value-relation.cc')
-rw-r--r--gcc/value-relation.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index 3fb7b96..fed8a78 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -32,9 +32,7 @@ along with GCC; see the file COPYING3. If not see
#include "alloc-pool.h"
#include "dominance.h"
-#define VREL_LAST VREL_PE64
-
-static const char *kind_string[VREL_LAST + 1] =
+static const char *kind_string[VREL_LAST] =
{ "varying", "undefined", "<", "<=", ">", ">=", "==", "!=", "pe8", "pe16",
"pe32", "pe64" };
@@ -47,7 +45,7 @@ print_relation (FILE *f, relation_kind rel)
}
// This table is used to negate the operands. op1 REL op2 -> !(op1 REL op2).
-relation_kind rr_negate_table[VREL_LAST + 1] = {
+relation_kind rr_negate_table[VREL_LAST] = {
VREL_VARYING, VREL_UNDEFINED, VREL_GE, VREL_GT, VREL_LE, VREL_LT, VREL_NE,
VREL_EQ };
@@ -60,7 +58,7 @@ relation_negate (relation_kind r)
}
// This table is used to swap the operands. op1 REL op2 -> op2 REL op1.
-relation_kind rr_swap_table[VREL_LAST + 1] = {
+relation_kind rr_swap_table[VREL_LAST] = {
VREL_VARYING, VREL_UNDEFINED, VREL_GT, VREL_GE, VREL_LT, VREL_LE, VREL_EQ,
VREL_NE };
@@ -74,7 +72,7 @@ relation_swap (relation_kind r)
// This table is used to perform an intersection between 2 relations.
-relation_kind rr_intersect_table[VREL_LAST + 1][VREL_LAST + 1] = {
+relation_kind rr_intersect_table[VREL_LAST][VREL_LAST] = {
// VREL_VARYING
{ VREL_VARYING, VREL_UNDEFINED, VREL_LT, VREL_LE, VREL_GT, VREL_GE, VREL_EQ,
VREL_NE },
@@ -112,7 +110,7 @@ relation_intersect (relation_kind r1, relation_kind r2)
// This table is used to perform a union between 2 relations.
-relation_kind rr_union_table[VREL_LAST + 1][VREL_LAST + 1] = {
+relation_kind rr_union_table[VREL_LAST][VREL_LAST] = {
// VREL_VARYING
{ VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING,
VREL_VARYING, VREL_VARYING, VREL_VARYING },
@@ -150,7 +148,7 @@ relation_union (relation_kind r1, relation_kind r2)
// This table is used to determine transitivity between 2 relations.
// (A relation0 B) and (B relation1 C) implies (A result C)
-relation_kind rr_transitive_table[VREL_LAST + 1][VREL_LAST + 1] = {
+relation_kind rr_transitive_table[VREL_LAST][VREL_LAST] = {
// VREL_VARYING
{ VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING, VREL_VARYING,
VREL_VARYING, VREL_VARYING, VREL_VARYING },
@@ -187,7 +185,7 @@ relation_transitive (relation_kind r1, relation_kind r2)
// This vector maps a relation to the equivalent tree code.
-tree_code relation_to_code [VREL_LAST + 1] = {
+tree_code relation_to_code [VREL_LAST] = {
ERROR_MARK, ERROR_MARK, LT_EXPR, LE_EXPR, GT_EXPR, GE_EXPR, EQ_EXPR,
NE_EXPR };
@@ -226,7 +224,8 @@ relation_oracle::validate_relation (relation_kind rel, vrange &op1, vrange &op2)
// If the relation cannot be folded for any reason, leave as is.
Value_Range result (boolean_type_node);
- if (!handler.fold_range (result, boolean_type_node, op1, op2, rel))
+ if (!handler.fold_range (result, boolean_type_node, op1, op2,
+ relation_trio::op1_op2 (rel)))
return rel;
// The expression op1 REL op2 using REL should fold to [1,1].