From: Andrew Pinski <apinski@marvell.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Andrew Pinski <apinski@marvell.com>
Subject: [PATCH] MATCH: Port CLRSB part of builtin_zero_pattern
Date: Sun, 30 Apr 2023 14:12:48 -0700 [thread overview]
Message-ID: <20230430211248.761908-1-apinski@marvell.com> (raw)
This ports the clrsb builtin part of builtin_zero_pattern
to match.pd. A simple pattern to port.
OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
* match.pd (a != 0 ? CLRSB(a) : CST -> CLRSB(a)): New
pattern.
---
gcc/match.pd | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gcc/match.pd b/gcc/match.pd
index 0e782cde71d..bf918ba70ce 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -7787,6 +7787,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(cond (ne @0 integer_zerop@1) (func@4 (convert? @2)) integer_zerop@3)
@4))
+/* a != 0 ? FUN(a) : CST -> Fun(a) for some CLRSB builtins
+ where CST is precision-1. */
+(for func (CLRSB)
+ (simplify
+ (cond (ne @0 integer_zerop@1) (func@5 (convert?@4 @2)) INTEGER_CST@3)
+ (if (wi::to_widest (@3) == TYPE_PRECISION (TREE_TYPE (@4)) - 1)
+ @5)))
+
#if GIMPLE
/* a != 0 ? CLZ(a) : CST -> .CLZ(a) where CST is the result of the internal function for 0. */
(for func (CLZ)
--
2.31.1
next reply other threads:[~2023-04-30 21:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-30 21:12 Andrew Pinski [this message]
2023-05-02 12:21 ` Richard Biener
2023-05-02 21:49 ` 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=20230430211248.761908-1-apinski@marvell.com \
--to=apinski@marvell.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).