public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Philipp Tomsich <ptomsich@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/vrull/heads/for-upstream)] RISC-V: branch-(not)equals-zero compares against $zero
Date: Thu, 17 Nov 2022 22:24:46 +0000 (GMT)	[thread overview]
Message-ID: <20221117222447.4D7F93858004@sourceware.org> (raw)

https://gcc.gnu.org/g:920c4e200b48631e7ddb8f213f031fb3ecb333ef

commit 920c4e200b48631e7ddb8f213f031fb3ecb333ef
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Sun Aug 30 21:02:36 2020 +0200

    RISC-V: branch-(not)equals-zero compares against $zero
    
    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.
    
    Series-to: gcc-patches@gcc.gnu.org
    Series-cc: Palmer Dabbelt <palmer@rivosinc.com>
    Series-cc: Vineet Gupta <vineetg@rivosinc.com>
    Series-cc: Christoph Muellner <christoph.muellner@vrull.eu>
    Series-cc: Kito Cheng <kito.cheng@gmail.com>
    Series-cc: Jeff Law <jlaw@ventanamicro.com>

Diff:
---
 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 0469882c80d..3d4a1cba096 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2216,6 +2216,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

             reply	other threads:[~2022-11-17 22:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 22:24 Philipp Tomsich [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-11-18 20:25 Philipp Tomsich
2022-11-18 20:22 Philipp Tomsich
2022-11-18 11:34 Philipp Tomsich
2022-11-15 14:00 Philipp Tomsich

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=20221117222447.4D7F93858004@sourceware.org \
    --to=ptomsich@gcc.gnu.org \
    --cc=gcc-cvs@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).