aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorWayne Zuo <wdvxdr1123@gmail.com>2022-03-02 16:32:16 +0800
committerKeith Randall <khr@golang.org>2022-04-04 20:07:23 +0000
commit7fbabe8d57de184c75bc938fa619235711bc4229 (patch)
treed3fb18f4bcafc1d1c1e8f2146f82ecb0cd17cf04 /test/codegen
parent6f1dce0fcb03f22402dac00f66a42b8b0f5bef2b (diff)
downloadgo-7fbabe8d57de184c75bc938fa619235711bc4229.tar.xz
cmd/compile: use shlx&shrx instruction for GOAMD64>=v3
The SHRX/SHLX instruction can take any general register as the shift count operand, and can read source from memory. This CL introduces some operators to combine load and shift to one instruction. For #47120 Change-Id: I13b48f53c7d30067a72eb2c8382242045dead36a Reviewed-on: https://go-review.googlesource.com/c/go/+/385174 Reviewed-by: Keith Randall <khr@golang.org> Trust: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/bmi.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/codegen/bmi.go b/test/codegen/bmi.go
index 0c25e0b796..2908d1b796 100644
--- a/test/codegen/bmi.go
+++ b/test/codegen/bmi.go
@@ -45,3 +45,19 @@ func blsr32(x int32) int32 {
// amd64/v3:"BLSRL"
return x & (x - 1)
}
+
+func shlrx64(x []uint64, i int, s uint64) uint64 {
+ // amd64/v3: `SHRXQ\t[A-Z]+[0-9]*, \([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
+ s = x[i] >> i
+ // amd64/v3: `SHLXQ\t[A-Z]+[0-9]*, 8\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*8\), [A-Z]+[0-9]*`
+ s = x[i+1] << s
+ return s
+}
+
+func shlrx32(x []uint32, i int, s uint32) uint32 {
+ // amd64/v3: `SHRXL\t[A-Z]+[0-9]*, \([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
+ s = x[i] >> i
+ // amd64/v3: `SHLXL\t[A-Z]+[0-9]*, 4\([A-Z]+[0-9]*\)\([A-Z]+[0-9]*\*4\), [A-Z]+[0-9]*`
+ s = x[i+1] << s
+ return s
+}