Add a simple assembly implementation of Count/CountString for mips64x.
name old sec/op new sec/op vs base
CountSingle/10-4 31.16n ± 0% 41.69n ± 0% +33.79% (p=0.000 n=11)
CountSingle/32-4 69.58n ± 0% 59.61n ± 0% -14.33% (p=0.000 n=11)
CountSingle/4K-4 7.428µ ± 0% 5.153µ ± 0% -30.63% (p=0.000 n=11)
CountSingle/4M-4 7.634m ± 0% 5.300m ± 0% -30.58% (p=0.000 n=11)
CountSingle/64M-4 134.4m ± 0% 100.8m ± 3% -24.99% (p=0.000 n=11)
name old B/s new B/s vs base
CountSingle/10-4 306.1Mi ± 0% 228.8Mi ± 0% -25.25% (p=0.000 n=11)
CountSingle/32-4 438.6Mi ± 0% 512.0Mi ± 0% +16.74% (p=0.000 n=11)
CountSingle/4K-4 525.9Mi ± 0% 758.0Mi ± 0% +44.15% (p=0.000 n=11)
CountSingle/4M-4 523.9Mi ± 0% 754.7Mi ± 0% +44.05% (p=0.000 n=11)
CountSingle/64M-4 476.3Mi ± 0% 635.0Mi ± 0% +33.31% (p=0.000 n=11)
Change-Id: Id5ddbea0d080e2903156ef8dc86c030a8179115b
Reviewed-on: https://go-review.googlesource.com/c/go/+/650995
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build !amd64 && !arm && !arm64 && !ppc64le && !ppc64 && !riscv64 && !s390x
+//go:build !amd64 && !arm && !arm64 && !mips64le && !mips64 && !ppc64le && !ppc64 && !riscv64 && !s390x
package bytealg
--- /dev/null
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build mips64 || mips64le
+
+#include "go_asm.h"
+#include "textflag.h"
+
+TEXT ·Count(SB),NOSPLIT,$0-40
+ // R1 = b_base
+ // R2 = b_len
+ // R3 = byte to count
+ MOVV b_base+0(FP), R1
+ MOVV b_len+8(FP), R2
+ MOVBU c+24(FP), R3
+ MOVV R0, R5 // count
+ ADDV R1, R2 // end
+
+loop:
+ BEQ R1, R2, done
+ MOVBU (R1), R6
+ ADDV $1, R1
+ BNE R3, R6, loop
+ ADDV $1, R5
+ JMP loop
+
+done:
+ MOVV R5, ret+32(FP)
+ RET
+
+TEXT ·CountString(SB),NOSPLIT,$0-32
+ // R1 = s_base
+ // R2 = s_len
+ // R3 = byte to count
+ MOVV s_base+0(FP), R1
+ MOVV s_len+8(FP), R2
+ MOVBU c+16(FP), R3
+ MOVV R0, R5 // count
+ ADDV R1, R2 // end
+
+loop:
+ BEQ R1, R2, done
+ MOVBU (R1), R6
+ ADDV $1, R1
+ BNE R3, R6, loop
+ ADDV $1, R5
+ JMP loop
+
+done:
+ MOVV R5, ret+24(FP)
+ RET
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build amd64 || arm || arm64 || ppc64le || ppc64 || riscv64 || s390x
+//go:build amd64 || arm || arm64 || mips64le || mips64 || ppc64le || ppc64 || riscv64 || s390x
package bytealg