aboutsummaryrefslogtreecommitdiff
path: root/test/codegen/mathbits.go
diff options
context:
space:
mode:
authorXiaolin Zhao <zhaoxiaolin@loongson.cn>2024-11-02 15:40:13 +0800
committerabner chenc <chenguoqi@loongson.cn>2024-11-11 00:08:45 +0000
commit583d750fa119d504686c737be6a898994b674b69 (patch)
tree3b238fc1b0a889da5b4c35032599b288d02c19f9 /test/codegen/mathbits.go
parent4b89120b124f96153c0eff3ae09975b5abb7333f (diff)
downloadgo-583d750fa119d504686c737be6a898994b674b69.tar.xz
cmd/compile: wire up bits.Reverse intrinsics for loong64
Micro-benchmark results on Loongson 3A5000 and 3A6000: goos: linux goarch: loong64 pkg: math/bits cpu: Loongson-3A6000 @ 2500.00MHz | CL 624576 | this CL | | sec/op | sec/op vs base | Reverse 2.8130n ± 0% 0.8008n ± 0% -71.53% (p=0.000 n=20) Reverse8 0.7014n ± 0% 0.4040n ± 0% -42.40% (p=0.000 n=20) Reverse16 1.2975n ± 0% 0.6632n ± 1% -48.89% (p=0.000 n=20) Reverse32 2.7520n ± 0% 0.4042n ± 0% -85.31% (p=0.000 n=20) Reverse64 2.8970n ± 0% 0.4041n ± 0% -86.05% (p=0.000 n=20) geomean 1.828n 0.5116n -72.01% goos: linux goarch: loong64 pkg: math/bits cpu: Loongson-3A5000 @ 2500.00MHz | CL 624576 | this CL | | sec/op | sec/op vs base | Reverse 4.0050n ± 0% 0.8011n ± 0% -80.00% (p=0.000 n=20) Reverse8 0.8010n ± 0% 0.5210n ± 1% -34.96% (p=0.000 n=20) Reverse16 1.6160n ± 0% 0.6008n ± 0% -62.82% (p=0.000 n=20) Reverse32 3.8550n ± 0% 0.5179n ± 0% -86.57% (p=0.000 n=20) Reverse64 3.8050n ± 0% 0.5177n ± 0% -86.40% (p=0.000 n=20) geomean 2.378n 0.5828n -75.49% Updates #59120 This patch is a copy of CL 483656. Co-authored-by: WANG Xuerui <git@xen0n.name> Change-Id: I98681091763279279c8404bd0295785f13ea1c8e Reviewed-on: https://go-review.googlesource.com/c/go/+/624276 Reviewed-by: abner chenc <chenguoqi@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'test/codegen/mathbits.go')
-rw-r--r--test/codegen/mathbits.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/codegen/mathbits.go b/test/codegen/mathbits.go
index 715f67a3c8..a3d1143424 100644
--- a/test/codegen/mathbits.go
+++ b/test/codegen/mathbits.go
@@ -199,6 +199,35 @@ func OnesCount8(n uint8) int {
return bits.OnesCount8(n)
}
+// ------------------ //
+// bits.Reverse //
+// ------------------ //
+
+func Reverse(n uint) uint {
+ // loong64:"BITREVV"
+ return bits.Reverse(n)
+}
+
+func Reverse64(n uint64) uint64 {
+ // loong64:"BITREVV"
+ return bits.Reverse64(n)
+}
+
+func Reverse32(n uint32) uint32 {
+ // loong64:"BITREVW"
+ return bits.Reverse32(n)
+}
+
+func Reverse16(n uint16) uint16 {
+ // loong64:"BITREV4B","REVB2H"
+ return bits.Reverse16(n)
+}
+
+func Reverse8(n uint8) uint8 {
+ // loong64:"BITREV4B"
+ return bits.Reverse8(n)
+}
+
// ----------------------- //
// bits.ReverseBytes //
// ----------------------- //