From: HAO CHEN GUI <guihaoc@linux.ibm.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
David <dje.gcc@gmail.com>, "Kewen.Lin" <linkw@linux.ibm.com>,
Peter Bergner <bergner@linux.ibm.com>
Subject: [PATCH v4, rs6000] Add a combine pattern for CA minus one [PR95737]
Date: Fri, 13 May 2022 09:07:54 +0800 [thread overview]
Message-ID: <243c7199-e6a5-f04b-568c-64024590695f@linux.ibm.com> (raw)
Hi,
This patch adds a combine pattern for "CA minus one". As CA only has two
values (0 or 1), we could convert following pattern
(sign_extend:DI (plus:SI (reg:SI 98 ca)
(const_int -1 [0xffffffffffffffff]))))
to
(plus:DI (reg:DI 98 ca)
(const_int -1 [0xffffffffffffffff])))
With this patch, one unnecessary sign extend is eliminated.
Bootstrapped and tested on powerpc64-linux BE and LE with no regressions.
Is this okay for trunk? Any recommendations? Thanks a lot.
ChangeLog
2022-05-13 Haochen Gui <guihaoc@linux.ibm.com>
gcc/
PR target/95737
* config/rs6000/rs6000.md (extenddi_ca_minus_one): Define.
gcc/testsuite/
PR target/95737
* gcc.target/powerpc/pr95737.c: New.
patch.diff
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 64049a6e521..483a93956f8 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -2353,6 +2353,19 @@ (define_insn "subf<mode>3_carry_in_xx"
"subfe %0,%0,%0"
[(set_attr "type" "add")])
+(define_insn_and_split "*extenddi_ca_minus_one"
+ [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
+ (sign_extend:DI (plus:SI (reg:SI CA_REGNO)
+ (const_int -1))))]
+ ""
+ "#"
+ ""
+ [(parallel [(set (match_dup 0)
+ (plus:DI (reg:DI CA_REGNO)
+ (const_int -1)))
+ (clobber (reg:DI CA_REGNO))])]
+ ""
+)
(define_insn "@neg<mode>2"
[(set (match_operand:GPR 0 "gpc_reg_operand" "=r")
diff --git a/gcc/testsuite/gcc.target/powerpc/pr95737.c b/gcc/testsuite/gcc.target/powerpc/pr95737.c
new file mode 100644
index 00000000000..d4d6a4198cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr95737.c
@@ -0,0 +1,10 @@
+/* PR target/95737 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2 -mno-isel" } */
+/* { dg-final { scan-assembler-not {\mextsw\M} } } */
+
+
+unsigned long negativeLessThan (unsigned long a, unsigned long b)
+{
+ return -(a < b);
+}
next reply other threads:[~2022-05-13 1:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 1:07 HAO CHEN GUI [this message]
2022-05-13 2:40 ` Kewen.Lin
2022-05-13 13:32 ` Segher Boessenkool
2022-05-13 13:21 ` Segher Boessenkool
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=243c7199-e6a5-f04b-568c-64024590695f@linux.ibm.com \
--to=guihaoc@linux.ibm.com \
--cc=bergner@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=linkw@linux.ibm.com \
--cc=segher@kernel.crashing.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).