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] Use existing tree code for *DIV_EXPR entries.
Date: Fri, 11 Nov 2022 14:53:15 +0100 [thread overview]
Message-ID: <20221111135318.235387-2-aldyh@redhat.com> (raw)
In-Reply-To: <20221111135318.235387-1-aldyh@redhat.com>
There is no need for a special tree code in the *DIV_EXPR entries, as
the parent class has one.
gcc/ChangeLog:
* range-op.cc (class operator_div): Remove tree code.
(operator_div::wi_op_overflows): Handle EXACT_DIV_EXPR as
TRUNC_DIV_EXPR.
---
gcc/range-op.cc | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 1fbebd85620..00a736e983d 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -1971,7 +1971,6 @@ operator_mult::wi_fold (irange &r, tree type,
class operator_div : public cross_product_operator
{
public:
- operator_div (enum tree_code c) { code = c; }
virtual void wi_fold (irange &r, tree type,
const wide_int &lh_lb,
const wide_int &lh_ub,
@@ -1983,8 +1982,6 @@ public:
virtual bool fold_range (irange &r, tree type,
const irange &lh, const irange &rh,
relation_trio trio) const final override;
-private:
- enum tree_code code;
};
bool
@@ -1995,7 +1992,7 @@ operator_div::fold_range (irange &r, tree type,
if (!cross_product_operator::fold_range (r, type, lh, rh, trio))
return false;
- update_known_bitmask (r, code, lh, rh);
+ update_known_bitmask (r, m_code, lh, rh);
return true;
}
@@ -2009,13 +2006,9 @@ operator_div::wi_op_overflows (wide_int &res, tree type,
wi::overflow_type overflow = wi::OVF_NONE;
signop sign = TYPE_SIGN (type);
- switch (code)
+ switch (m_code)
{
case EXACT_DIV_EXPR:
- // EXACT_DIV_EXPR is implemented as TRUNC_DIV_EXPR in
- // operator_exact_divide. No need to handle it here.
- gcc_unreachable ();
- break;
case TRUNC_DIV_EXPR:
res = wi::div_trunc (w0, w1, sign, &overflow);
break;
@@ -2091,17 +2084,11 @@ operator_div::wi_fold (irange &r, tree type,
gcc_checking_assert (!r.undefined_p ());
}
-operator_div op_trunc_div (TRUNC_DIV_EXPR);
-operator_div op_floor_div (FLOOR_DIV_EXPR);
-operator_div op_round_div (ROUND_DIV_EXPR);
-operator_div op_ceil_div (CEIL_DIV_EXPR);
-
class operator_exact_divide : public operator_div
{
using range_operator::op1_range;
public:
- operator_exact_divide () : operator_div (TRUNC_DIV_EXPR) { }
virtual bool op1_range (irange &r, tree type,
const irange &lhs,
const irange &op2,
@@ -4382,6 +4369,10 @@ 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;
+static operator_div op_trunc_div;
+static operator_div op_floor_div;
+static operator_div op_round_div;
+static operator_div op_ceil_div;
// Instantiate a range op table for integral operations.
--
2.38.1
next prev parent 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 [COMMITTED] [range-ops] Add tree code to range_operator Aldy Hernandez
2022-11-11 13:53 ` Aldy Hernandez [this message]
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-2-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).