Hello, On Mon, Sep 29 2025, Kalvakuntla, Umesh wrote: > Hello, > >> -----Original Message----- >> From: Martin Jambor <[email protected]> >> Sent: Monday, September 29, 2025 5:16 PM >> To: Kalvakuntla, Umesh <[email protected]>; gcc- >> [email protected] >> Cc: Gopalasubramanian, Ganesh <[email protected]>; Jan >> Hubicka <[email protected]> >> Subject: RE: [PATCH] [X86] Fixes for AMD znver5 enablement >> >> Caution: This message originated from an External Source. Use proper caution >> when opening attachments, clicking links, or responding. >> >> >> Hello, >> >> On Fri, Sep 26 2025, Kalvakuntla, Umesh wrote: >> > [AMD Official Use Only - AMD Internal Distribution Only] >> > >> > Hello Martin, >> > >> > Can you please commit this? I don't have the required rights. >> >> Honza is in favor, so I think I can. Can you please write the corresponding >> ChangeLog and provide information how the patch has been tested? > > Tested the patch with below command on znver5 machine: > $ gcc -Q -march=native --help=target | grep prefetchi > -mprefetchi [enabled] > > Model numbers are updated as per specification. > > Updated patch with Changelog :
I have pushed the following to the master branch. Thanks, Martin >From 578c322e7d6a6b5e392d7b587179e3031b7a8daa Mon Sep 17 00:00:00 2001 From: Umesh Kalvakuntla <[email protected]> Date: Wed, 8 Oct 2025 18:50:37 +0200 Subject: [PATCH] x86: Fixes for AMD znver5 enablement 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 <[email protected]> * 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 | 12 +++++++++++- gcc/config/i386/cpuid.h | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h index c93ea07239a..3f29f17e2a5 100644 --- a/gcc/common/config/i386/cpuinfo.h +++ b/gcc/common/config/i386/cpuinfo.h @@ -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 } diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index afd4ef06e9f..25e28352f59 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -72,6 +72,10 @@ #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) -- 2.51.0
