aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorJeff Law <jlaw@ventanamicro.com>2024-05-09 21:07:06 -0600
committerJeff Law <jlaw@ventanamicro.com>2024-05-09 21:07:06 -0600
commitbfb88b1406cdd8d3f97e280b0d63529aa925f18a (patch)
treee87b120cb851e363f33e3c8f0bc7a70ba5016030 /gcc/config
parentd7bb8eaade3cd3aa70715c8567b4d7b08098e699 (diff)
downloadgcc-bfb88b1406cdd8d3f97e280b0d63529aa925f18a.zip
gcc-bfb88b1406cdd8d3f97e280b0d63529aa925f18a.tar.gz
gcc-bfb88b1406cdd8d3f97e280b0d63529aa925f18a.tar.bz2
[committed] [RISC-V] Provide splitting guidance to combine to faciliate shNadd.uw generation
This fixes a minor code quality issue I found while comparing GCC and LLVM. Essentially we want to do a bit of re-association to generate shNadd.uw instructions. Combine does the right thing and finds all the necessary instructions, reassociates the operands, combines constants, etc. Where is fails is finding a good split point. The backend can trivially provide guidance on how to split via a define_split pattern. This has survived both Ventana's internal CI system (rv64gcb) as well as my own (rv64gc, rv32gcv). I'll wait for the external CI system to give the all-clear before pushing. gcc/ * config/riscv/bitmanip.md: Add splitter for shadd feeding another add instruction. gcc/testsuite/ * gcc.target/riscv/zba-shadduw.c: New test.
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/riscv/bitmanip.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md
index ad3ad75..d76a72d 100644
--- a/gcc/config/riscv/bitmanip.md
+++ b/gcc/config/riscv/bitmanip.md
@@ -184,6 +184,23 @@
[(set_attr "type" "bitmanip")
(set_attr "mode" "DI")])
+;; Combine will reassociate the operands in the most useful way here. We
+;; just have to give it guidance on where to split the result to facilitate
+;; shNadd.uw generation.
+(define_split
+ [(set (match_operand:DI 0 "register_operand")
+ (plus:DI (plus:DI (and:DI (ashift:DI (match_operand:DI 1 "register_operand")
+ (match_operand:QI 2 "imm123_operand"))
+ (match_operand 3 "consecutive_bits32_operand"))
+ (match_operand:DI 4 "register_operand"))
+ (match_operand 5 "immediate_operand")))]
+ "TARGET_64BIT && TARGET_ZBA"
+ [(set (match_dup 0)
+ (plus:DI (and:DI (ashift:DI (match_dup 1) (match_dup 2))
+ (match_dup 3))
+ (match_dup 4)))
+ (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 5)))])
+
;; ZBB extension.
(define_expand "clzdi2"