From: Philipp Tomsich <philipp.tomsich@vrull.eu>
To: gcc-patches@gcc.gnu.org
Cc: Vineet Gupta <vineetg@rivosinc.com>,
Kito Cheng <kito.cheng@gmail.com>,
Jeff Law <jlaw@ventanamicro.com>,
Palmer Dabbelt <palmer@rivosinc.com>,
Christoph Muellner <christoph.muellner@vrull.eu>,
Philipp Tomsich <philipp.tomsich@vrull.eu>
Subject: [PATCH] RISC-V: branch-(not)equals-zero compares against $zero
Date: Tue, 8 Nov 2022 20:55:09 +0100 [thread overview]
Message-ID: <20221108195509.2701313-1-philipp.tomsich@vrull.eu> (raw)
If we are testing a register or a paradoxical subreg (i.e. anything that is not
a partial subreg) for equality/non-equality with zero, we can generate a branch
that compares against $zero. This will work for QI, HI, SI and DImode, so we
enable this for ANYI.
2020-08-30 gcc/ChangeLog:
* config/riscv/riscv.md (*branch<mode>_equals_zero): Added pattern.
---
gcc/config/riscv/riscv.md | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 798f7370a08..97f6ca37891 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2205,6 +2205,19 @@
;; Conditional branches
+(define_insn "*branch<mode>_equals_zero"
+ [(set (pc)
+ (if_then_else
+ (match_operator 1 "equality_operator"
+ [(match_operand:ANYI 2 "register_operand" "r")
+ (const_int 0)])
+ (label_ref (match_operand 0 "" ""))
+ (pc)))]
+ "!partial_subreg_p (operands[2])"
+ "b%C1\t%2,zero,%0"
+ [(set_attr "type" "branch")
+ (set_attr "mode" "none")])
+
(define_insn "*branch<mode>"
[(set (pc)
(if_then_else
--
2.34.1
next reply other threads:[~2022-11-08 19:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-08 19:55 Philipp Tomsich [this message]
2022-11-17 22:44 ` Jeff Law
2022-11-18 4:53 ` Palmer Dabbelt
2022-11-18 9:14 ` Philipp Tomsich
2022-11-19 16:47 ` Jeff Law
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=20221108195509.2701313-1-philipp.tomsich@vrull.eu \
--to=philipp.tomsich@vrull.eu \
--cc=christoph.muellner@vrull.eu \
--cc=gcc-patches@gcc.gnu.org \
--cc=jlaw@ventanamicro.com \
--cc=kito.cheng@gmail.com \
--cc=palmer@rivosinc.com \
--cc=vineetg@rivosinc.com \
/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).