From patchwork Wed Sep 17 06:15:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umesh Kalvakuntla X-Patchwork-Id: 120411 Return-Path: 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 ; 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 ; 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 To: gcc-patches@gcc.gnu.org Cc: Ganesh Gopalasubramanian , Umesh Kalvakuntla 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org From: Umesh Kalvakuntla - 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)) { 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)