shithub: dav1d

Download patch

ref: 493155af054cf29a4dead7ffe92acd5d6b3d6a59
parent: d7c3420b69d225fb2aff1165138690fbd17a67d8
author: Henrik Gramner <gramner@twoorioles.com>
date: Fri Mar 1 17:21:21 EST 2019

x86: Check for BMI1 and BMI2 flags in addition to AVX2

All known AVX2-capable CPU:s has BMI1 and BMI2, but apparently some
x86 emulators can be configured to emulate esoteric combinations of
instruction sets that doesn't correspond to any existing hardware.

--- a/src/x86/cpu.c
+++ b/src/x86/cpu.c
@@ -57,7 +57,8 @@
                 if (info[2] & (1 << 28)) flags |= DAV1D_X86_CPU_FLAG_AVX;
                 if (n_ids >= 7) {
                     dav1d_cpu_cpuid(info, 7);
-                    if (info[1] & (1 <<  5)) flags |= DAV1D_X86_CPU_FLAG_AVX2;
+                    if ((info[1] & 0x00000128) == 0x00000128)
+                        flags |= DAV1D_X86_CPU_FLAG_AVX2;
                     if ((xcr & 0x000000e0) == 0x000000e0) /* ZMM/OPMASK */ {
                         if ((info[1] & 0xd0030000) == 0xd0030000)
                             flags |= DAV1D_X86_CPU_FLAG_AVX512;