Debian Codegraph @

simd/cpu_amd64.go

raw
1 //go:build amd64
2
3 package simd
4
5 import (
6 "golang.org/x/sys/cpu"
7 )
8
9 // hasAVX2 gates every AVX2 kernel in this package. golang.org/x/sys/cpu
10 // verifies both the CPU capability and OS support for saving the YMM
11 // register state, and the value is read once at init so the per-call
12 // dispatch is a single predictable branch.
13 var hasAVX2 = cpu.X86.HasAVX2
14
15 // hasPOPCNT gates countNonASCIIAVX2, the one kernel that reaches outside
16 // the AVX/AVX2 instruction set: its remainder loop turns a vector's
17 // high-bit mask into a lane count with POPCNT, whose CPUID bit
18 // (01H:ECX[23]) is independent of AVX2's. Every shipping AVX2 part has
19 // POPCNT, but a hypervisor can mask the two separately, and an ungated
20 // POPCNT would be SIGILL rather than a fallback — so the count dispatch
21 // checks both and drops to the SWAR path if either is missing.
22 var hasPOPCNT = cpu.X86.HasPOPCNT