Skip to content

Commit 1776255

Browse files
HeliC829gopherbot
authored andcommitted
internal/bytealg: add assembly implementation of Count/CountString for mips64x
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Keith Randall <[email protected]>
1 parent d7a1261 commit 1776255

File tree

3 files changed

+54
-2
lines changed

3 files changed

+54
-2
lines changed

src/internal/bytealg/count_generic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build !amd64 && !arm && !arm64 && !ppc64le && !ppc64 && !riscv64 && !s390x
5+
//go:build !amd64 && !arm && !arm64 && !mips64le && !mips64 && !ppc64le && !ppc64 && !riscv64 && !s390x
66

77
package bytealg
88

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright 2025 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build mips64 || mips64le
6+
7+
#include "go_asm.h"
8+
#include "textflag.h"
9+
10+
TEXT ·Count(SB),NOSPLIT,$0-40
11+
// R1 = b_base
12+
// R2 = b_len
13+
// R3 = byte to count
14+
MOVV b_base+0(FP), R1
15+
MOVV b_len+8(FP), R2
16+
MOVBU c+24(FP), R3
17+
MOVV R0, R5 // count
18+
ADDV R1, R2 // end
19+
20+
loop:
21+
BEQ R1, R2, done
22+
MOVBU (R1), R6
23+
ADDV $1, R1
24+
BNE R3, R6, loop
25+
ADDV $1, R5
26+
JMP loop
27+
28+
done:
29+
MOVV R5, ret+32(FP)
30+
RET
31+
32+
TEXT ·CountString(SB),NOSPLIT,$0-32
33+
// R1 = s_base
34+
// R2 = s_len
35+
// R3 = byte to count
36+
MOVV s_base+0(FP), R1
37+
MOVV s_len+8(FP), R2
38+
MOVBU c+16(FP), R3
39+
MOVV R0, R5 // count
40+
ADDV R1, R2 // end
41+
42+
loop:
43+
BEQ R1, R2, done
44+
MOVBU (R1), R6
45+
ADDV $1, R1
46+
BNE R3, R6, loop
47+
ADDV $1, R5
48+
JMP loop
49+
50+
done:
51+
MOVV R5, ret+24(FP)
52+
RET

src/internal/bytealg/count_native.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build amd64 || arm || arm64 || ppc64le || ppc64 || riscv64 || s390x
5+
//go:build amd64 || arm || arm64 || mips64le || mips64 || ppc64le || ppc64 || riscv64 || s390x
66

77
package bytealg
88

0 commit comments

Comments
 (0)