diff options
| author | Wayne Zuo <wdvxdr@golangcn.org> | 2022-09-06 11:43:28 +0800 |
|---|---|---|
| committer | Joel Sing <joel@sing.id.au> | 2022-10-06 05:21:04 +0000 |
| commit | af668c689c66588f8adb9f5cd6db812706536338 (patch) | |
| tree | 1537804de703171a60a5996aac6228e84d9aab28 /test/codegen | |
| parent | b314eea4cdba0755caedc9a3e683d3f7e1e2be6f (diff) | |
| download | go-af668c689c66588f8adb9f5cd6db812706536338.tar.xz | |
cmd/compile: fold constant shift with extension on riscv64
For example:
movb a0, a0
srai $1, a0, a0
the assembler will expand to:
slli $56, a0, a0
srai $56, a0, a0
srai $1, a0, a0
this CL optimize to:
slli $56, a0, a0
srai $57, a0, a0
Remove 270+ instructions from Go binary on linux/riscv64.
Change-Id: I375e19f9d3bd54f2781791d8cbe5970191297dc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/428496
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/shift.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/codegen/shift.go b/test/codegen/shift.go index c82566bb10..4a9f5d4356 100644 --- a/test/codegen/shift.go +++ b/test/codegen/shift.go @@ -34,21 +34,21 @@ func rshConst64x64(v int64) int64 { func lshConst32x64(v int32) int32 { // ppc64:"SLW" // ppc64le:"SLW" - // riscv64:"SLLI",-"AND",-"SLTIU" + // riscv64:"SLLI",-"AND",-"SLTIU", -"MOVW" return v << uint64(29) } func rshConst32Ux64(v uint32) uint32 { // ppc64:"SRW" // ppc64le:"SRW" - // riscv64:"SRLI",-"AND",-"SLTIU" + // riscv64:"SRLI",-"AND",-"SLTIU", -"MOVW" return v >> uint64(29) } func rshConst32x64(v int32) int32 { // ppc64:"SRAW" // ppc64le:"SRAW" - // riscv64:"SRAI",-"OR",-"SLTIU" + // riscv64:"SRAI",-"OR",-"SLTIU", -"MOVW" return v >> uint64(29) } |
