diff --git a/common/include/x86emitter/x86_intrin.h b/common/include/x86emitter/x86_intrin.h index 5ee21d892e..43d4c6214a 100644 --- a/common/include/x86emitter/x86_intrin.h +++ b/common/include/x86emitter/x86_intrin.h @@ -34,7 +34,6 @@ #define cpuid __cpuid #define cpuidex __cpuidex -#define xgetbv _xgetbv #else @@ -50,21 +49,6 @@ static __inline__ __attribute__((always_inline)) void cpuid(int CPUInfo[], const __cpuid(InfoType, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); } -#if defined(__clang__) || __GNUC__ < 8 || (__GNUC__ == 8 && __GNUC_MINOR__ < 2) -// _xgetbv on gcc 8.1 is broken (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85684). -// It also isn't present on clang and earlier versions of gcc. -static __inline__ __attribute__((always_inline)) unsigned long long xgetbv(unsigned int index) -{ - unsigned int eax, edx; - __asm__ __volatile__("xgetbv" - : "=a"(eax), "=d"(edx) - : "c"(index)); - return ((unsigned long long)edx << 32) | eax; -} -#else -#define xgetbv _xgetbv -#endif - #endif // Rotate instruction diff --git a/common/src/x86emitter/cpudetect.cpp b/common/src/x86emitter/cpudetect.cpp index 0111a98c54..2530008520 100644 --- a/common/src/x86emitter/cpudetect.cpp +++ b/common/src/x86emitter/cpudetect.cpp @@ -297,12 +297,12 @@ void x86capabilities::Identify() if ((Flags2 >> 27) & 1) // OSXSAVE { - if ((xgetbv(0) & 6) == 6) // XFEATURE_ENABLED_MASK[2:1] = '11b' (XMM state and YMM state are enabled by OS). - { - hasAVX = (Flags2 >> 28) & 1; //avx - hasFMA = (Flags2 >> 12) & 1; //fma - hasAVX2 = (SEFlag >> 5) & 1; //avx2 - } + // Note: In theory, we should use xgetbv to check OS support + // but all OSes we officially run under support it + // and its intrinsic requires extra compiler flags + hasAVX = (Flags2 >> 28) & 1; //avx + hasFMA = (Flags2 >> 12) & 1; //fma + hasAVX2 = (SEFlag >> 5) & 1; //avx2 } hasBMI1 = (SEFlag >> 3) & 1;