summaryrefslogtreecommitdiff
path: root/libavutil/x86
diff options
context:
space:
mode:
authorAlan Kelly <alankelly-at-google.com@ffmpeg.org>2021-12-21 20:56:41 +0100
committerJames Almer <jamrial@gmail.com>2021-12-21 17:44:44 -0300
commitffbab99f2c22be06ef3c564fd38320d40e48a2b5 (patch)
tree1fe8ee8fadcd36aab7fba56c03801f893e4e7d76 /libavutil/x86
parent14b6805eb29d193105998e530e92525d7fe98d6d (diff)
libavutil/cpu: Add AV_CPU_FLAG_SLOW_GATHER.
This flag is set on Haswell and earlier and all AMD cpus.
Diffstat (limited to 'libavutil/x86')
-rw-r--r--libavutil/x86/cpu.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index bcd41a50a2..441b4695d5 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -146,8 +146,21 @@ int ff_get_cpu_flags_x86(void)
if (max_std_level >= 7) {
cpuid(7, eax, ebx, ecx, edx);
#if HAVE_AVX2
- if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x00000020))
+ if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x00000020)) {
rval |= AV_CPU_FLAG_AVX2;
+ cpuid(1, eax, ebx, ecx, std_caps);
+ family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
+ model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
+ /* Haswell has slow gather */
+ if (!strncmp(vendor.c, "GenuineIntel", 12))
+ if (family == 6 && model < 70)
+ rval |= AV_CPU_FLAG_SLOW_GATHER;
+ /* Zen 3 and earlier have slow gather */
+ if (!strncmp(vendor.c, "AuthenticAMD", 12))
+ if (family <= 0x19)
+ rval |= AV_CPU_FLAG_SLOW_GATHER;
+ }
+
#if HAVE_AVX512 /* F, CD, BW, DQ, VL */
if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */
if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd0030000) == 0xd0030000)