]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/ssa: expand runtime.memequal for length {3,5,6,7}
authorYoulin Feng <fengyoulin@live.com>
Thu, 4 Sep 2025 01:08:14 +0000 (09:08 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 9 Sep 2025 19:10:07 +0000 (12:10 -0700)
commita5fa5ea51cd8fd9bcb8230d2accf9d55826f76b3
treef1966aae45ec96a4c378aef6b1ebfbe357a6ffab
parent4c63d798cb947a3cdd5a5b68f254a73d83eb288f
cmd/compile/internal/ssa: expand runtime.memequal for length {3,5,6,7}

This CL slightly speeds up strings.HasPrefix when testing constant
prefixes of length {3,5,6,7}.

goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
                │      old     │                 new                 │
                │    sec/op    │   sec/op     vs base                │
StringPrefix3-8   11.125n ± 2%   8.539n ± 1%  -23.25% (p=0.000 n=20)
StringPrefix5-8   11.170n ± 2%   8.700n ± 1%  -22.11% (p=0.000 n=20)
StringPrefix6-8   11.190n ± 2%   8.655n ± 1%  -22.65% (p=0.000 n=20)
StringPrefix7-8   11.095n ± 1%   8.878n ± 1%  -19.98% (p=0.000 n=20)

Change-Id: I510a80d59cf78680b57d68780d35d212d24030e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/700816
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/_gen/generic.rules
src/cmd/compile/internal/ssa/rewritegeneric.go
test/codegen/strings.go