From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: "hernandez, aldy" <aldyh@redhat.com>
Subject: [PATCH 17/17] Convert CFN_BUILT_IN_PARITY to range-ops.
Date: Thu, 22 Sep 2022 15:10:45 -0400 [thread overview]
Message-ID: <d97e89ef-7296-3cf4-3e52-e9aedcbc7432@redhat.com> (raw)
In-Reply-To: <571782f9-72e6-5c30-da55-b8d62d3a153e@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 188 bytes --]
Also, as the last builtin remaining, also remove the builtin
infrastructure routines from fold_using_range.
Bootstrapped on x86_64-pc-linux-gnu with no regressions. Pushed.
Andrew
[-- Attachment #2: 0017-Convert-CFN_BUILT_IN_PARITY-to-range-ops.patch --]
[-- Type: text/x-patch, Size: 5405 bytes --]
From 5608e410914ebb7c8cc9fa50afc8ada3b22cbf2c Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Tue, 20 Sep 2022 19:30:46 -0400
Subject: [PATCH 17/17] Convert CFN_BUILT_IN_PARITY to range-ops.
Also, as the last builtin remaining, also remove the builtin infrastrucure
routines from fold_using_range.
* gimple-range-fold.cc (range_of_range_op): Handle no operands.
(range_of_call): Do not check for builtins.
(fold_using_range::range_of_builtin_call): Delete.
(fold_using_range::range_of_builtin_int_call): Delete.
* gimple-range-fold.h: Adjust prototypes.
* gimple-range-op.cc (class cfn_parity): New.
(gimple_range_op_handler::maybe_builtin_call): Set arguments.
---
gcc/gimple-range-fold.cc | 60 ++++++++--------------------------------
gcc/gimple-range-fold.h | 4 ---
gcc/gimple-range-op.cc | 19 +++++++++++++
3 files changed, 31 insertions(+), 52 deletions(-)
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 5e8a13e7337..c381ef94087 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -534,6 +534,16 @@ fold_using_range::range_of_range_op (vrange &r,
tree lhs = handler.lhs ();
tree op1 = handler.operand1 ();
tree op2 = handler.operand2 ();
+
+ // Certain types of builtin functions may have no arguments.
+ if (!op1)
+ {
+ Value_Range r1 (type);
+ if (!handler.fold_range (r, type, r1, r1))
+ r.set_varying (type);
+ return true;
+ }
+
Value_Range range1 (TREE_TYPE (op1));
Value_Range range2 (op2 ? TREE_TYPE (op2) : TREE_TYPE (op1));
@@ -823,7 +833,7 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src)
// If a range cannot be calculated, return false.
bool
-fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &src)
+fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &)
{
tree type = gimple_range_type (call);
if (!type)
@@ -832,9 +842,7 @@ fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &src)
tree lhs = gimple_call_lhs (call);
bool strict_overflow_p;
- if (range_of_builtin_call (r, call, src))
- ;
- else if (gimple_stmt_nonnegative_warnv_p (call, &strict_overflow_p))
+ if (gimple_stmt_nonnegative_warnv_p (call, &strict_overflow_p))
r.set_nonnegative (type);
else if (gimple_call_nonnull_result_p (call)
|| gimple_call_nonnull_arg (call))
@@ -852,50 +860,6 @@ fold_using_range::range_of_call (vrange &r, gcall *call, fur_source &src)
return true;
}
-// For a builtin in CALL, return a range in R if known and return
-// TRUE. Otherwise return FALSE.
-
-bool
-fold_using_range::range_of_builtin_call (vrange &r, gcall *call,
- fur_source &src)
-{
- combined_fn func = gimple_call_combined_fn (call);
- if (func == CFN_LAST)
- return false;
-
- tree type = gimple_range_type (call);
- gcc_checking_assert (type);
-
- if (irange::supports_p (type))
- return range_of_builtin_int_call (as_a <irange> (r), call, src);
-
- return false;
-}
-
-bool
-fold_using_range::range_of_builtin_int_call (irange &r, gcall *call,
- fur_source &)
-{
- combined_fn func = gimple_call_combined_fn (call);
- if (func == CFN_LAST)
- return false;
-
- tree type = gimple_range_type (call);
- scalar_int_mode mode;
-
- switch (func)
- {
- CASE_CFN_PARITY:
- r.set (build_zero_cst (type), build_one_cst (type));
- return true;
-
- default:
- break;
- }
- return false;
-}
-
-
// Calculate a range for COND_EXPR statement S and return it in R.
// If a range cannot be calculated, return false.
diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h
index ce18c66b8e7..d1ed2bca80f 100644
--- a/gcc/gimple-range-fold.h
+++ b/gcc/gimple-range-fold.h
@@ -165,10 +165,6 @@ protected:
bool range_of_call (vrange &r, gcall *call, fur_source &src);
bool range_of_cond_expr (vrange &r, gassign* cond, fur_source &src);
bool range_of_address (irange &r, gimple *s, fur_source &src);
- bool range_of_builtin_call (vrange &r, gcall *call, fur_source &src);
- bool range_of_builtin_int_call (irange &r, gcall *call, fur_source &src);
- void range_of_builtin_ubsan_call (irange &r, gcall *call, tree_code code,
- fur_source &src);
bool range_of_phi (vrange &r, gphi *phi, fur_source &src);
void range_of_ssa_name_with_loop_info (vrange &, tree, class loop *, gphi *,
fur_source &src);
diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
index 76295466e65..d7c6dfa933d 100644
--- a/gcc/gimple-range-op.cc
+++ b/gcc/gimple-range-op.cc
@@ -663,6 +663,20 @@ private:
bool m_is_pos;
} op_cfn_goacc_dim_size (false), op_cfn_goacc_dim_pos (true);
+
+// Implement range operator for CFN_BUILT_IN_
+class cfn_parity : public range_operator
+{
+public:
+ using range_operator::fold_range;
+ virtual bool fold_range (irange &r, tree type, const irange &,
+ const irange &, relation_kind) const
+ {
+ r.set (build_zero_cst (type), build_one_cst (type));
+ return true;
+ }
+} op_cfn_parity;
+
// Set up a gimple_range_op_handler for any built in function which can be
// supported via range-ops.
@@ -795,6 +809,11 @@ gimple_range_op_handler::maybe_builtin_call ()
m_int = &op_cfn_goacc_dim_pos;
break;
+ CASE_CFN_PARITY:
+ m_valid = true;
+ m_int = &op_cfn_parity;
+ break;
+
default:
break;
}
--
2.37.3
prev parent reply other threads:[~2022-09-22 19:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-22 18:49 [PATCH 00/17] Move builtin functions " Andrew MacLeod
2022-09-22 18:53 ` [PATCH 01/17] Replace another snippet with a call to, gimple_range_ssa_names Andrew MacLeod
2022-09-22 18:55 ` [PATCH 02/17] Adjust range_op_handler to store the handler directly Andrew MacLeod
2022-09-22 18:56 ` [PATCH 03/17] Create gimple_range_op_handler in a new source file Andrew MacLeod
2022-09-22 18:58 ` [PATCH 04/17] Fix calc_op1 for undefined op2_range Andrew MacLeod
2022-09-22 18:59 ` [PATCH 05/17] Add missing float fold_range prototype for floats Andrew MacLeod
2022-09-22 19:00 ` [PATCH 06/17] Always check the return value of fold_range Andrew MacLeod
2022-09-22 19:01 ` [PATCH 07/17] Add range-ops support for builtin functions Andrew MacLeod
2022-09-22 19:02 ` [PATCH 08/17] Convert CFN_BUILT_IN_SIGNBIT to range-ops Andrew MacLeod
2022-09-22 19:05 ` [PATCH 09/17] Convert CFN_BUILT_IN_TOUPPER and TOLOWER " Andrew MacLeod
2022-09-22 19:05 ` [PATCH 10/17] Convert CFN_BUILT_FFS and CFN_POPCOUNT " Andrew MacLeod
2022-09-22 19:05 ` [PATCH 11/17] Convert CFN_CLZ builtins " Andrew MacLeod
2022-09-22 19:05 ` [PATCH 12/17] Convert CFN_CTZ " Andrew MacLeod
2022-09-22 19:06 ` [PATCH 13/17] Convert CFN_BUILT_IN_CLRSB " Andrew MacLeod
2022-09-22 19:06 ` [PATCH 14/17] Convert CFN_BUILT_IN_UBSAN_CHECK_* " Andrew MacLeod
2022-09-22 19:08 ` [PATCH 15/17] Convert CFN_BUILT_IN_STRLEN " Andrew MacLeod
2022-09-22 19:10 ` [PATCH 16/17] Convert CFN_BUILT_IN_GOACC_DIM_* " Andrew MacLeod
2022-09-22 19:10 ` Andrew MacLeod [this message]
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=d97e89ef-7296-3cf4-3e52-e9aedcbc7432@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).