aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorJoel Sing <joel@sing.id.au>2024-08-19 23:54:17 +1000
committerJoel Sing <joel@sing.id.au>2024-08-28 13:46:24 +0000
commite126129d7612349874828685c2bcd49de498a1a0 (patch)
tree28a045d64afb4b0b1392179757b9614d24e30780 /test/codegen
parentaeac0b6cbfb42bc9c9301913a191bb09454d316a (diff)
downloadgo-e126129d7612349874828685c2bcd49de498a1a0.tar.xz
cmd/compile/internal/ssa: combine shift and addition for riscv64 rva22u64
When GORISCV64 enables rva22u64, combined shift and addition using the SH1ADD, SH2ADD and SH3ADD instructions that are available via the Zba extension. This results in more than 2000 instructions being removed from the Go binary on riscv64. Change-Id: Ia62ae7dda3d8083cff315113421bee73f518eea8 Reviewed-on: https://go-review.googlesource.com/c/go/+/606636 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Meng Zhuo <mengzhuo1203@gmail.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/shift.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/codegen/shift.go b/test/codegen/shift.go
index 6a2a6c40cd..bc91c61baa 100644
--- a/test/codegen/shift.go
+++ b/test/codegen/shift.go
@@ -520,3 +520,20 @@ func checkShiftToMask(u []uint64, s []int64) {
// amd64:-"SHR",-"SHL","ANDQ"
u[1] = u[1] << 5 >> 5
}
+
+//
+// Left shift with addition.
+//
+
+func checkLeftShiftWithAddition(a int64, b int64) int64 {
+ // riscv64/rva20u64: "SLLI","ADD"
+ // riscv64/rva22u64: "SH1ADD"
+ a = a + b<<1
+ // riscv64/rva20u64: "SLLI","ADD"
+ // riscv64/rva22u64: "SH2ADD"
+ a = a + b<<2
+ // riscv64/rva20u64: "SLLI","ADD"
+ // riscv64/rva22u64: "SH3ADD"
+ a = a + b<<3
+ return a
+}