[FFmpeg-cvslog] avutil/cpu: move slow gather checks below in the function

James Almer git at videolan.org
Tue Dec 21 22:56:24 EET 2021


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Dec 21 17:39:02 2021 -0300| [8c2d2fd6ccca4e389cb9dac4ab190965e97868a4] | committer: James Almer

avutil/cpu: move slow gather checks below in the function

Put them together with other similar slow flag checks.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c2d2fd6ccca4e389cb9dac4ab190965e97868a4
---

 libavutil/x86/cpu.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index 441b4695d5..7b13fcae91 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -146,21 +146,8 @@ 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)
@@ -209,6 +196,10 @@ int ff_get_cpu_flags_x86(void)
            used unless explicitly disabled by checking AV_CPU_FLAG_AVXSLOW. */
             if ((family == 0x15 || family == 0x16) && (rval & AV_CPU_FLAG_AVX))
                 rval |= AV_CPU_FLAG_AVXSLOW;
+
+        /* Zen 3 and earlier have slow gather */
+            if ((family <= 0x19) && (rval & AV_CPU_FLAG_AVX2))
+                rval |= AV_CPU_FLAG_SLOW_GATHER;
         }
 
         /* XOP and FMA4 use the AVX instruction coding scheme, so they can't be
@@ -248,6 +239,10 @@ int ff_get_cpu_flags_x86(void)
         if ((rval & AV_CPU_FLAG_SSSE3) && !(rval & AV_CPU_FLAG_SSE4) &&
             family == 6 && model < 23)
             rval |= AV_CPU_FLAG_SSSE3SLOW;
+
+        /* Haswell has slow gather */
+        if ((rval & AV_CPU_FLAG_AVX2) && family == 6 && model < 70)
+            rval |= AV_CPU_FLAG_SLOW_GATHER;
     }
 
 #endif /* cpuid */



More information about the ffmpeg-cvslog mailing list