Skip to content

Commit cf39bcf

Browse files
committed
Switch on AVX2
1 parent ef57843 commit cf39bcf

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module github.com/jeschkies/go-memmem
22

3-
go 1.22
3+
go 1.21
44

55

6-
toolchain go1.22.1
6+
toolchain go1.21.3
77

88
require (
99
github.com/mmcloughlin/avo v0.5.0

pkg/search/asm.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ func main() {
2323
Store(offset, ReturnIndex(0))
2424
RET()
2525

26-
TEXT("indexAvx512", NOSPLIT, "func(haystack, needle []byte) int64")
27-
Doc("indexAvx512 returns the first position the needle is in the haystack.")
26+
TEXT("indexAvx2", NOSPLIT, "func(haystack, needle []byte) int64")
27+
Doc("indexAvx2 returns the first position the needle is in the haystack.")
2828

2929
needlePtr := Load(Param("needle").Base(), GP64())
3030
needleLenMain := Load(Param("needle").Len(), GP64()); DECQ(needleLenMain)

pkg/search/bytes_avx512_amd64.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/search/bytes_avx512_amd64.s

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ test_chunk_match:
104104
MOVQ SI, ret+48(FP)
105105
RET
106106

107-
// func indexAvx512(haystack []byte, needle []byte) int64
107+
// func indexAvx2(haystack []byte, needle []byte) int64
108108
// Requires: AVX, AVX2, BMI
109-
TEXT ·indexAvx512(SB), NOSPLIT, $0-56
109+
TEXT ·indexAvx2(SB), NOSPLIT, $0-56
110110
MOVQ needle_base+24(FP), AX
111111
MOVQ needle_len+32(FP), CX
112112
DECQ CX

pkg/search/init_amd64.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
)
88

99
func init() {
10-
if cpu.X86.HasAVX512 {
11-
index = indexAvx512
10+
if cpu.X86.HasAVX2 {
11+
index = indexAvx2
1212
} else {
1313
index = func(haystack []byte, needle []byte) int64 { return int64(bytes.Index(haystack, needle)) }
1414
}

0 commit comments

Comments
 (0)