[AMD Official Use Only - AMD Internal Distribution Only]
> -----Original Message-----
> From: Martin Jambor <[email protected]>
> Sent: Monday, September 22, 2025 6:14 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 Wed, Sep 17 2025, Umesh Kalvakuntla wrote:
> > From: Umesh Kalvakuntla <[email protected]>
> >
> > - cpuid bit for prefetchi is different from Intel
> > (https://docs.amd.com/v/u/en-US/24594_3.37)
> > - Fix cpu family model numbers
> > ---
> > gcc/common/config/i386/cpuinfo.h | 11 +++++++++++
> > gcc/config/i386/cpuid.h | 4 ++++
> > 2 files changed, 15 insertions(+)
> >
> > diff --git a/gcc/common/config/i386/cpuinfo.h
> > b/gcc/common/config/i386/cpuinfo.h
> > index c93ea07239a..6b45e1b0531 100644
> > --- a/gcc/common/config/i386/cpuinfo.h
> > +++ b/gcc/common/config/i386/cpuinfo.h
> > @@ -313,6 +313,8 @@ get_amd_cpu (struct __processor_model *cpu_model,
> > case 0x1a:
> > cpu_model->__cpu_type = AMDFAM1AH;
> > if (model <= 0x77)
> > + if (model <= 0x4f || (model >= 0x60 && model <= 0x77) ||
> > + (model >= 0xd0 && model <= 0xd7))
>
> I assume you did not want to leave the "if (model <= 0x77)" there but wanted
> to
> remove it?
Hello Martin,
Yes, my bad. Please find the updated patch.
Thanks,
Umesh
---
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..dac01d887f1 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.43.0
>
> Thanks,
>
> Martin
>
> > {
> > cpu = "znver5";
> > CHECK___builtin_cpu_is ("znver5"); @@ -1102,6 +1104,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..dac01d887f1 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.43.0