cpuid tells us whether the O/S uses extended state management via
XSAVE/XRSTOR, but we have to call xgetbv to verify that it is using
XSAVE/XRSTOR to manage the state of XMM/YMM registers.
test rcx, 1<<28
jz short .return ; CPU does not support AVX2
+ xor rcx, rcx
+ xgetbv
+ test rax, 6 ; O/S does not manage XMM/YMM state
+ ; using XSAVE
+ jz short .return
+
or rdi, JSIMD_AVX2
.return:
pushfd
pop eax
xor eax, edx
- jz short .return ; CPUID is not supported
+ jz near .return ; CPUID is not supported
; Check for MMX instruction support
xor eax, eax
cpuid
test eax, eax
- jz short .return
+ jz near .return
xor eax, eax
inc eax
test ecx, 1<<28
jz short .no_avx2 ; CPU does not support AVX2
+ xor ecx, ecx
+ xgetbv
+ test eax, 6 ; O/S does not manage XMM/YMM state
+ ; using XSAVE
+ jz short .no_avx2
+
or edi, JSIMD_AVX2
.no_avx2: