From: Aldy Hernandez <aldyh@redhat.com>
To: GCC patches <gcc-patches@gcc.gnu.org>
Cc: Andrew MacLeod <amacleod@redhat.com>, Aldy Hernandez <aldyh@redhat.com>
Subject: [COMMITTED] [range-ops] Add tree code to range_operator.
Date: Fri, 11 Nov 2022 14:53:14 +0100 [thread overview]
Message-ID: <20221111135318.235387-1-aldyh@redhat.com> (raw)
This patch adds a tree code to range_operator in order to known which
tree code to pass into bit-CCP.
Up to now range-ops has been free of tree details, with the exception
of the div entries which use a tree code to differentiate between
them. This is still the goal going forward, but this is a stop-gap
until we can merge the CCP and range-op bit handling in the next
release.
No change in performance.
gcc/ChangeLog:
* range-op.cc: (range_op_table::set): Set m_code.
(integral_table::integral_table): Handle shared entries.
(pointer_table::pointer_table): Same.
* range-op.h (class range_operator): Add m_code.
---
gcc/range-op.cc | 37 +++++++++++++++++++++++--------------
gcc/range-op.h | 5 +++++
2 files changed, 28 insertions(+), 14 deletions(-)
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 8ff5d5b4c78..1fbebd85620 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -2523,7 +2523,7 @@ private:
const irange &outer) const;
void fold_pair (irange &r, unsigned index, const irange &inner,
const irange &outer) const;
-} op_convert;
+};
// Add a partial equivalence between the LHS and op1 for casts.
@@ -3877,7 +3877,7 @@ public:
const irange &op1,
const irange &op2,
relation_kind rel) const;
-} op_identity;
+};
// Determine if there is a relationship between LHS and OP1.
@@ -3922,7 +3922,7 @@ public:
const irange &op1,
const irange &op2,
relation_trio rel = TRIO_VARYING) const;
-} op_unknown;
+};
bool
operator_unknown::fold_range (irange &r, tree type,
@@ -4245,7 +4245,7 @@ public:
virtual void wi_fold (irange & r, tree type,
const wide_int &lh_lb, const wide_int &lh_ub,
const wide_int &rh_lb, const wide_int &rh_ub) const;
-} op_ptr_min_max;
+};
void
pointer_min_max_operator::wi_fold (irange &r, tree type,
@@ -4372,8 +4372,17 @@ range_op_table::set (enum tree_code code, range_operator &op)
{
gcc_checking_assert (m_range_tree[code] == NULL);
m_range_tree[code] = &op;
+ gcc_checking_assert (op.m_code == ERROR_MARK || op.m_code == code);
+ op.m_code = code;
}
+// Shared operators that require separate instantiations because they
+// do not share a common tree code.
+static operator_cast op_nop, op_convert;
+static operator_identity op_ssa, op_paren, op_obj_type;
+static operator_unknown op_realpart, op_imagpart;
+static pointer_min_max_operator op_ptr_min, op_ptr_max;
+
// Instantiate a range op table for integral operations.
class integral_table : public range_op_table
@@ -4402,7 +4411,7 @@ integral_table::integral_table ()
set (EXACT_DIV_EXPR, op_exact_div);
set (LSHIFT_EXPR, op_lshift);
set (RSHIFT_EXPR, op_rshift);
- set (NOP_EXPR, op_convert);
+ set (NOP_EXPR, op_nop);
set (CONVERT_EXPR, op_convert);
set (TRUTH_AND_EXPR, op_logical_and);
set (BIT_AND_EXPR, op_bitwise_and);
@@ -4413,11 +4422,11 @@ integral_table::integral_table ()
set (TRUTH_NOT_EXPR, op_logical_not);
set (BIT_NOT_EXPR, op_bitwise_not);
set (INTEGER_CST, op_integer_cst);
- set (SSA_NAME, op_identity);
- set (PAREN_EXPR, op_identity);
- set (OBJ_TYPE_REF, op_identity);
- set (IMAGPART_EXPR, op_unknown);
- set (REALPART_EXPR, op_unknown);
+ set (SSA_NAME, op_ssa);
+ set (PAREN_EXPR, op_paren);
+ set (OBJ_TYPE_REF, op_obj_type);
+ set (IMAGPART_EXPR, op_imagpart);
+ set (REALPART_EXPR, op_realpart);
set (POINTER_DIFF_EXPR, op_pointer_diff);
set (ABS_EXPR, op_abs);
set (ABSU_EXPR, op_absu);
@@ -4437,8 +4446,8 @@ pointer_table::pointer_table ()
{
set (BIT_AND_EXPR, op_pointer_and);
set (BIT_IOR_EXPR, op_pointer_or);
- set (MIN_EXPR, op_ptr_min_max);
- set (MAX_EXPR, op_ptr_min_max);
+ set (MIN_EXPR, op_ptr_min);
+ set (MAX_EXPR, op_ptr_max);
set (POINTER_PLUS_EXPR, op_pointer_plus);
set (EQ_EXPR, op_equal);
@@ -4447,10 +4456,10 @@ pointer_table::pointer_table ()
set (LE_EXPR, op_le);
set (GT_EXPR, op_gt);
set (GE_EXPR, op_ge);
- set (SSA_NAME, op_identity);
+ set (SSA_NAME, op_ssa);
set (INTEGER_CST, op_integer_cst);
set (ADDR_EXPR, op_addr);
- set (NOP_EXPR, op_convert);
+ set (NOP_EXPR, op_nop);
set (CONVERT_EXPR, op_convert);
set (BIT_NOT_EXPR, op_bitwise_not);
diff --git a/gcc/range-op.h b/gcc/range-op.h
index 442a6e1d299..c999b456f62 100644
--- a/gcc/range-op.h
+++ b/gcc/range-op.h
@@ -48,7 +48,9 @@ along with GCC; see the file COPYING3. If not see
class range_operator
{
+ friend class range_op_table;
public:
+ range_operator () : m_code (ERROR_MARK) { }
// Perform an operation between 2 ranges and return it.
virtual bool fold_range (irange &r, tree type,
const irange &lh,
@@ -106,6 +108,9 @@ protected:
const wide_int &lh_ub,
const wide_int &rh_lb,
const wide_int &rh_ub) const;
+
+ // Tree code of the range operator or ERROR_MARK if unknown.
+ tree_code m_code;
};
// Like range_operator above, but for floating point operators.
--
2.38.1
next reply other threads:[~2022-11-11 13:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 13:53 Aldy Hernandez [this message]
2022-11-11 13:53 ` [COMMITTED] [range-ops] Use existing tree code for *DIV_EXPR entries Aldy Hernandez
2022-11-11 13:53 ` [COMMITTED] [range-ops] Update known bitmasks using CCP for all operators Aldy Hernandez
2022-11-11 13:53 ` [COMMITTED] [range-ops] Avoid unnecessary intersection in update_known_bitmask Aldy Hernandez
2022-11-11 13:53 ` [COMMITTED] [range-ops] Remove specialized fold_range methods for various operators Aldy Hernandez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221111135318.235387-1-aldyh@redhat.com \
--to=aldyh@redhat.com \
--cc=amacleod@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).