From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "hernandez, aldy" <aldyh@redhat.com>
Subject: [COMMITTED 11/17] - Add a hybrid MIN_EXPR operator for integer and pointer.
Date: Mon, 12 Jun 2023 11:32:58 -0400 [thread overview]
Message-ID: <f5eccc69-b7df-f3cc-74b7-421e0ea4247e@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 156 bytes --]
Add a hybrid operator to choose between integer and pointer versions at
runtime.
Bootstraps on x86_64-pc-linux-gnu with no regressions. Pushed.
Andrew
[-- Attachment #2: 0011-Add-a-hybrid-MIN_EXPR-operator-for-integer-and-point.patch --]
[-- Type: text/x-patch, Size: 3464 bytes --]
From 08f2e419b1e29f114857b3d817904abf3b4891be Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Sat, 10 Jun 2023 16:34:26 -0400
Subject: [PATCH 11/17] Add a hybrid MIN_EXPR operator for integer and pointer.
This adds an operator to the unified table for MIN_EXPR which will
select either the pointer or integer version based on the type passed
to the method. This is for use until we have a seperate PRANGE class.
* range-op-mixed.h (operator_min): Remove final.
* range-op-ptr.cc (pointer_table::pointer_table): Remove MIN_EXPR.
(class hybrid_min_operator): New.
(range_op_table::initialize_pointer_ops): Add hybrid_min_operator.
* range-op.cc (unified_table::unified_table): Comment out MIN_EXPR.
---
gcc/range-op-mixed.h | 6 +++---
gcc/range-op-ptr.cc | 28 +++++++++++++++++++++++++++-
gcc/range-op.cc | 2 +-
3 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index e4852e974c4..a65935435c2 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -625,11 +625,11 @@ class operator_min : public range_operator
{
public:
void update_bitmask (irange &r, const irange &lh,
- const irange &rh) const final override;
-private:
+ const irange &rh) const override;
+protected:
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 final override;
+ const wide_int &rh_ub) const override;
};
class operator_max : public range_operator
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 7b22d0bf05b..483e43ca994 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -270,7 +270,6 @@ operator_pointer_diff::op1_op2_relation_effect (irange &lhs_range, tree type,
pointer_table::pointer_table ()
{
- set (MIN_EXPR, op_ptr_min_max);
set (MAX_EXPR, op_ptr_min_max);
}
@@ -380,6 +379,32 @@ public:
}
} op_hybrid_or;
+// Temporary class which dispatches routines to either the INT version or
+// the pointer version depending on the type. Once PRANGE is a range
+// class, we can remove the hybrid.
+
+class hybrid_min_operator : public operator_min
+{
+public:
+ void update_bitmask (irange &r, const irange &lh,
+ const irange &rh) const final override
+ {
+ if (!r.undefined_p () && INTEGRAL_TYPE_P (r.type ()))
+ operator_min::update_bitmask (r, lh, rh);
+ }
+
+ 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 final override
+ {
+ if (INTEGRAL_TYPE_P (type))
+ return operator_min::wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub);
+ else
+ return op_ptr_min_max.wi_fold (r, type, lh_lb, lh_ub, rh_lb, rh_ub);
+ }
+} op_hybrid_min;
+
+
// Initialize any pointer operators to the primary table
@@ -391,4 +416,5 @@ range_op_table::initialize_pointer_ops ()
set (POINTER_DIFF_EXPR, op_pointer_diff);
set (BIT_AND_EXPR, op_hybrid_and);
set (BIT_IOR_EXPR, op_hybrid_or);
+ set (MIN_EXPR, op_hybrid_min);
}
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 0a9a3297de7..481f3b1324d 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -123,7 +123,7 @@ unified_table::unified_table ()
// set (BIT_AND_EXPR, op_bitwise_and);
// set (BIT_IOR_EXPR, op_bitwise_or);
- set (MIN_EXPR, op_min);
+ // set (MIN_EXPR, op_min);
set (MAX_EXPR, op_max);
}
--
2.40.1
reply other threads:[~2023-06-12 15:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=f5eccc69-b7df-f3cc-74b7-421e0ea4247e@redhat.com \
--to=amacleod@redhat.com \
--cc=aldyh@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).