]> granicus.if.org Git - libjpeg-turbo/commitdiff
AVX2: Perform additional checks for O/S support
authorDRC <information@libjpeg-turbo.org>
Wed, 13 Jul 2016 21:03:36 +0000 (16:03 -0500)
committerDRC <information@libjpeg-turbo.org>
Wed, 13 Jul 2016 21:03:36 +0000 (16:03 -0500)
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.

simd/jsimdcpu-64.asm
simd/jsimdcpu.asm

index d0c2e5bf38c65f6b68775682e15d329233f22dc6..78d7309f5f4801f7c83ad74877dac32fe54c4fc6 100644 (file)
@@ -58,6 +58,12 @@ EXTN(jpeg_simd_cpu_support):
     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:
index 92782e2855ff26b2e90746c154055afc45bd09a1..827aefe417f0a175c4ddc9290b2244e9814e383a 100644 (file)
@@ -49,13 +49,13 @@ EXTN(jpeg_simd_cpu_support):
     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
@@ -92,6 +92,12 @@ EXTN(jpeg_simd_cpu_support):
     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: