From 185e49d2a99c9edd8adca92d45dd5ba02e9892de Mon Sep 17 00:00:00 2001 From: Techjar Date: Sun, 26 Jan 2020 22:08:55 -0500 Subject: [PATCH] x64CPUDetect: Add flag for slow PDEP/PEXT on AMD Zen For some unknown reason PDEP and PEXT are ridiculously slow on AMD Zen architecture. --- Source/Core/Common/CPUDetect.h | 3 +++ Source/Core/Common/x64CPUDetect.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/Source/Core/Common/CPUDetect.h b/Source/Core/Common/CPUDetect.h index 7ecc3e00cd..f789ba41a2 100644 --- a/Source/Core/Common/CPUDetect.h +++ b/Source/Core/Common/CPUDetect.h @@ -42,6 +42,9 @@ struct CPUInfo bool bAVX2 = false; bool bBMI1 = false; bool bBMI2 = false; + // PDEP and PEXT are ridiculously slow on AMD Zen, so we have this flag to avoid using them there + // Zen 2 is also affected by this issue + bool bFastBMI2 = false; bool bFMA = false; bool bFMA4 = false; bool bAES = false; diff --git a/Source/Core/Common/x64CPUDetect.cpp b/Source/Core/Common/x64CPUDetect.cpp index 0c3decba05..338c74b808 100644 --- a/Source/Core/Common/x64CPUDetect.cpp +++ b/Source/Core/Common/x64CPUDetect.cpp @@ -175,6 +175,7 @@ void CPUInfo::Detect() } bFlushToZero = bSSE; + bFastBMI2 = bBMI2 && !bZen; if (max_ex_fn >= 0x80000004) {