package runtime

func cpuid(,  uint32) (, , ,  uint32)
func xgetbv() (,  uint32)

// HasAVX2 is whether the CPU and the OS support AVX2.
var HasAVX2 = detectAVX2()

func detectAVX2() bool {
	, , ,  := cpuid(0, 0)
	if  < 7 {
		return false
	}
	, , ,  := cpuid(1, 0)
	const ,  = 1 << 27, 1 << 28
	if & == 0 || & == 0 {
		return false
	}
	// the OS saves the YMM registers.
	if ,  := xgetbv(); &6 != 6 {
		return false
	}
	, , ,  := cpuid(7, 0)
	const  = 1 << 5
	return & != 0
}