From: Andrew Pinski <quic_apinski@quicinc.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Andrew Pinski <quic_apinski@quicinc.com>
Subject: [PATCH 1/2] builtins: Don't expand bit query builtins for __int128_t if the target supports an optab for it
Date: Fri, 16 Aug 2024 14:35:58 -0700 [thread overview]
Message-ID: <20240816213559.1486438-1-quic_apinski@quicinc.com> (raw)
On aarch64 (without !CSSC instructions), since popcount is implemented using the SIMD instruction cnt,
instead of using two SIMD cnt (V8QI mode), it is better to use one 128bit cnt (V16QI mode). And only one
reduction addition instead of 2. Currently fold_builtin_bit_query will expand always without checking
if there was an optab for the type, so this changes that to check the optab to see if we should expand
or have the backend handle it.
Bootstrapped and tested on x86_64-linux-gnu and built and tested for aarch64-linux-gnu.
gcc/ChangeLog:
* builtins.cc (fold_builtin_bit_query): Don't expand double
`unsigned long long` typess if there is an optab entry for that
type.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
gcc/builtins.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 0b902896ddd..b4d51eaeba5 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -10185,7 +10185,9 @@ fold_builtin_bit_query (location_t loc, enum built_in_function fcode,
tree call = NULL_TREE, tem;
if (TYPE_PRECISION (arg0_type) == MAX_FIXED_MODE_SIZE
&& (TYPE_PRECISION (arg0_type)
- == 2 * TYPE_PRECISION (long_long_unsigned_type_node)))
+ == 2 * TYPE_PRECISION (long_long_unsigned_type_node))
+ /* If the target supports the optab, then don't do the expansion. */
+ && !direct_internal_fn_supported_p (ifn, arg0_type, OPTIMIZE_FOR_BOTH))
{
/* __int128 expansions using up to 2 long long builtins. */
arg0 = save_expr (arg0);
--
2.43.0
next reply other threads:[~2024-08-16 21:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 21:35 Andrew Pinski [this message]
2024-08-16 21:35 ` [PATCH 2/2] aarch64: Implement popcountti2 pattern [PR113042] Andrew Pinski
2024-08-20 16:51 ` Richard Sandiford
2024-08-20 18:17 ` Richard Sandiford
2024-08-21 0:24 ` Andrew Pinski
2024-08-20 16:45 ` [PATCH 1/2] builtins: Don't expand bit query builtins for __int128_t if the target supports an optab for it Richard Sandiford
2024-08-21 0:22 ` Andrew Pinski
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=20240816213559.1486438-1-quic_apinski@quicinc.com \
--to=quic_apinski@quicinc.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).