[gcc(refs/vendors/vrull/heads/for-upstream)] RISC-V: branch-(not)equals-zero compares against $zero
Philipp Tomsich
ptomsich@gcc.gnu.org
Thu Nov 17 22:24:46 GMT 2022
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
More information about the Gcc-cvs
mailing list