| Message ID | 20250917061503.3082469-1-umesh.kalvakuntla@amd.com |
|---|---|
| State | New |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0F7353858C2C for <patchwork@sourceware.org>; Wed, 17 Sep 2025 06:16:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F7353858C2C X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from aocc-opt-04.amd.com (unknown [165.204.156.251]) by sourceware.org (Postfix) with ESMTPS id 81E1B3858D33 for <gcc-patches@gcc.gnu.org>; Wed, 17 Sep 2025 06:15:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81E1B3858D33 Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=aocc-opt-04.amd.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 81E1B3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=165.204.156.251 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758089720; cv=none; b=Yb93IvYPqMz/Sc8ahhTsSQ2/XmozRY3QbYOsHWFuEMJ9vn3D+yMVuZvVFM3w5C2grYbBjo3Vgs9YPKAHK+P4GevKv4UfM7NKhHHP2FdET2ZdOF33WyZ8mNsGPdFyprYyA9NZdAPoBctoFjBlf/FwRbX2ahnZK+yuGVMJmU8pWD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1758089720; c=relaxed/simple; bh=Zm/jLN0v0lsPBerCkSxlsdeoQ35CtPjyjmJ4mIDuxp8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=A9ilwZqWlWRdveSwt8TguVjf9ghBH27/FtY+VoocR3Ub9YejxH6Qv04uIJ+FMP/BWGqEAt0k5NciBwNj7to+nybfqMR9X+aAtnYRr7WG/6axBPS6BO6Yhx7llebrZelwaxQTpGAeI5xxYABbCg04jKqnHbhO0pgqz8iJePaNxeI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81E1B3858D33 Received: by aocc-opt-04.amd.com (Postfix, from userid 1000) id 10025401A8; Wed, 17 Sep 2025 11:45:18 +0530 (IST) From: Umesh Kalvakuntla <umesh.kalvakuntla@amd.com> To: gcc-patches@gcc.gnu.org Cc: Ganesh Gopalasubramanian <Ganesh.Gopalasubramanian@amd.com>, Umesh Kalvakuntla <Umesh.Kalvakuntla@amd.com> Subject: [PATCH] [X86] Fixes for AMD znver5 enablement Date: Wed, 17 Sep 2025 11:45:03 +0530 Message-ID: <20250917061503.3082469-1-umesh.kalvakuntla@amd.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, LOCAL_AUTHENTICATION_FAIL_DMARC, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
[X86] Fixes for AMD znver5 enablement
|
|
Commit Message
Umesh Kalvakuntla
Sept. 17, 2025, 6:15 a.m. UTC
From: Umesh Kalvakuntla <Umesh.Kalvakuntla@amd.com>
- 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(+)
Comments
Hello, On Wed, Sep 17 2025, Umesh Kalvakuntla wrote: > From: Umesh Kalvakuntla <Umesh.Kalvakuntla@amd.com> > > - 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? 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
[AMD Official Use Only - AMD Internal Distribution Only] > -----Original Message----- > From: Martin Jambor <mjambor@suse.cz> > Sent: Monday, September 22, 2025 6:14 PM > To: Kalvakuntla, Umesh <Umesh.Kalvakuntla@amd.com>; gcc- > patches@gcc.gnu.org > Cc: Gopalasubramanian, Ganesh <Ganesh.Gopalasubramanian@amd.com>; Jan > Hubicka <hubicka@ucw.cz> > 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 <Umesh.Kalvakuntla@amd.com> > > > > - 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
[AMD Official Use Only - AMD Internal Distribution Only] Hello Martin, Can you please commit this? I don't have the required rights. Thanks, Umesh > -----Original Message----- > From: Kalvakuntla, Umesh > Sent: Tuesday, September 23, 2025 10:40 AM > To: 'Martin Jambor' <mjambor@suse.cz>; gcc-patches@gcc.gnu.org > Cc: Gopalasubramanian, Ganesh <Ganesh.Gopalasubramanian@amd.com>; Jan > Hubicka <hubicka@ucw.cz> > Subject: RE: [PATCH] [X86] Fixes for AMD znver5 enablement > > > > > -----Original Message----- > > From: Martin Jambor <mjambor@suse.cz> > > Sent: Monday, September 22, 2025 6:14 PM > > To: Kalvakuntla, Umesh <Umesh.Kalvakuntla@amd.com>; gcc- > > patches@gcc.gnu.org > > Cc: Gopalasubramanian, Ganesh <Ganesh.Gopalasubramanian@amd.com>; > Jan > > Hubicka <hubicka@ucw.cz> > > 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 <Umesh.Kalvakuntla@amd.com> > > > > > > - 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
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? Thank you, Martin >> 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 >> >>
Hello, > -----Original Message----- > From: Martin Jambor <mjambor@suse.cz> > Sent: Monday, September 29, 2025 5:16 PM > To: Kalvakuntla, Umesh <Umesh.Kalvakuntla@amd.com>; gcc- > patches@gcc.gnu.org > Cc: Gopalasubramanian, Ganesh <Ganesh.Gopalasubramanian@amd.com>; Jan > Hubicka <hubicka@ucw.cz> > 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 : --- gcc/ChangeLog | 7 +++++++ gcc/common/config/i386/cpuinfo.h | 12 +++++++++++- gcc/config/i386/cpuid.h | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 63fd0f27d03..60a8a1af697 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +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. + 2025-09-28 liuhongt <hongtao.liu@intel.com> PR target/121970 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)
Hello, On Mon, Sep 29 2025, Kalvakuntla, Umesh wrote: > Hello, > >> -----Original Message----- >> From: Martin Jambor <mjambor@suse.cz> >> Sent: Monday, September 29, 2025 5:16 PM >> To: Kalvakuntla, Umesh <Umesh.Kalvakuntla@amd.com>; gcc- >> patches@gcc.gnu.org >> Cc: Gopalasubramanian, Ganesh <Ganesh.Gopalasubramanian@amd.com>; Jan >> Hubicka <hubicka@ucw.cz> >> 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 <Umesh.Kalvakuntla@amd.com> 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 <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 | 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)
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)) { 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)