From: Julian Zhu Date: Thu, 20 Feb 2025 13:55:28 +0000 (+0800) Subject: internal/bytealg: add assembly implementation of Count/CountString for mips64x X-Git-Tag: go1.25rc1~952 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=17762557421b912490498b815f28f71646b411fe;p=gostls13.git 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek Reviewed-by: Keith Randall Auto-Submit: Keith Randall --- diff --git a/src/internal/bytealg/count_generic.go b/src/internal/bytealg/count_generic.go index 932a7c584c..54bb100cbf 100644 --- a/src/internal/bytealg/count_generic.go +++ b/src/internal/bytealg/count_generic.go @@ -2,7 +2,7 @@ // 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 diff --git a/src/internal/bytealg/count_mips64x.s b/src/internal/bytealg/count_mips64x.s new file mode 100644 index 0000000000..247d0b35f4 --- /dev/null +++ b/src/internal/bytealg/count_mips64x.s @@ -0,0 +1,52 @@ +// 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 diff --git a/src/internal/bytealg/count_native.go b/src/internal/bytealg/count_native.go index 90189c9fe0..0a8caee87e 100644 --- a/src/internal/bytealg/count_native.go +++ b/src/internal/bytealg/count_native.go @@ -2,7 +2,7 @@ // 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