]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
x86: Fixes for AMD znver5 enablement
authorUmesh Kalvakuntla <Umesh.Kalvakuntla@amd.com>
Wed, 8 Oct 2025 16:50:37 +0000 (18:50 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Fri, 10 Oct 2025 13:51:24 +0000 (15:51 +0200)
This patch fixes cpu family model numbers for znver5 and uses the
correct cpuid bit for prefetchi which is different from Intel
(https://docs.amd.com/v/u/en-US/24594_3.37).

2025-09-29  Umesh Kalvakuntla <Umesh.Kalvakuntla@amd.com>

* common/config/i386/cpuinfo.h (get_amd_cpu): Fix znver5 family
model numbers.
(get_available_features): Set FEATURE_PREFETCHI for bit_AMD_PREFETCHI.
* config/i386/cpuid.h (bit_AMD_PREFETCHI): New Macro.

gcc/common/config/i386/cpuinfo.h
gcc/config/i386/cpuid.h

index c93ea07239ad9f7b3c68ee3226a72582773abce7..3f29f17e2a59b9eda26f87ff514bccf377972b49 100644 (file)
@@ -312,7 +312,8 @@ get_amd_cpu (struct __processor_model *cpu_model,
       break;
     case 0x1a:
       cpu_model->__cpu_type = AMDFAM1AH;
-      if (model <= 0x77)
+      if (model <= 0x4f || (model >= 0x60 && model <= 0x77) ||
+         (model >= 0xd0 && model <= 0xd7))
        {
          cpu = "znver5";
          CHECK___builtin_cpu_is ("znver5");
@@ -1102,6 +1103,15 @@ get_available_features (struct __processor_model *cpu_model,
        set_feature (FEATURE_WBNOINVD);
     }
 
+  if (ext_level >= 0x80000021)
+    {
+      __cpuid (0x80000021, eax, ebx, ecx, edx);
+      if (eax & bit_AMD_PREFETCHI)
+       {
+         set_feature (FEATURE_PREFETCHI);
+       }
+    }
+
 #undef set_feature
 }
 
index afd4ef06e9f7730fc575a3ca1624c5ae52f1227a..25e28352f596ccb212f03db4c404522a35a0cbcb 100644 (file)
 #define bit_CLZERO     (1 << 0)
 #define bit_WBNOINVD   (1 << 9)
 
+/* Extended Features (%eax == 0x80000021) */
+/* %eax */
+#define bit_AMD_PREFETCHI (1 << 20)
+
 /* Extended Features Leaf (%eax == 7, %ecx == 0) */
 /* %ebx */
 #define bit_FSGSBASE   (1 << 0)