From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 86F08386FC35 for ; Thu, 24 Jun 2021 12:12:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 86F08386FC35 Received: by mail-pf1-x431.google.com with SMTP id t32so5003844pfg.2 for ; Thu, 24 Jun 2021 05:12:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=td+r1xXyKTra8Kx/ifxRmHqQRWgqw881+13F6ECE6QA=; b=ecuLBxXP1CYdqB4JizXk4fUrgz4uu874NSHCFbo52RiOXkf3BwwMQvJLGXXpHBqplk hvuBi8C2EiCbbAxpoaZgd2Uw9pTXwkAnCT5DcTQDfoJY7mCudpRPSa9lhy04ELyuix7x 9rCaACdDN6ldkyH6JJKTms8Z9+05aMkQ3kDH0ufbf/FkN9vmQwFas1Eke0Zpqh2oyJuC PN6TyT4INk9PWHcXjvjAI3QZqe020cuioDntfn61cQqrJd3iDA5HKIqzZSdlEJ58FbAo GnN9+4IR0Py5xbuTVPlSITvTC/nuXxC/+PVs8uHMnE3JY2A5cckbwCr6Pqoy7Tho9B9Z Y0iw== X-Gm-Message-State: AOAM532j3vRQsfGbaKMJieCraK3kIvjFDHojKgHBWbT7pjRAiI7IH1WQ y3t14ZHx5Nu/45BQGscpkNMJB25lrU0= X-Google-Smtp-Source: ABdhPJzLrHG4NItTIyvIikTy/P4CwuBrJ+dDFOtcFGXtnGbaZ97qDxk41/OoPEXCm8xMmzNMwZewrQ== X-Received: by 2002:a63:4a4a:: with SMTP id j10mr4487173pgl.175.1624536735506; Thu, 24 Jun 2021 05:12:15 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.56.39.115]) by smtp.gmail.com with ESMTPSA id t13sm2923388pfq.173.2021.06.24.05.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Jun 2021 05:12:15 -0700 (PDT) Received: from gnu-cfl-2.. (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id DDB1CC0319; Thu, 24 Jun 2021 05:12:13 -0700 (PDT) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak , Hongtao Liu Subject: [PATCH] x86: Compile CPUID functions with -mgeneral-regs-only Date: Thu, 24 Jun 2021 05:12:13 -0700 Message-Id: <20210624121213.3469943-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3032.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2021 12:12:18 -0000 CPUID functions are used to detect CPU features. If vector ISAs are enabled, compiler is free to use them in these functions. Add __attribute__ ((target("general-regs-only"))) to CPUID functions to avoid vector instructions. gcc/ PR target/101185 * config/i386/cpuid.h (__get_cpuid_max): Add __attribute__ ((target("general-regs-only"))). (__get_cpuid): Likewise. (__get_cpuid_count): Likewise. (__cpuidex): Likewise. gcc/testsuite/ PR target/101185 * gcc.target/i386/avx512-check.h (check_osxsave): Add __attribute__ ((target("general-regs-only"))). (main): Likewise. --- gcc/config/i386/cpuid.h | 4 ++++ gcc/testsuite/gcc.target/i386/avx512-check.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/gcc/config/i386/cpuid.h b/gcc/config/i386/cpuid.h index aebc17c6827..74881ee91e5 100644 --- a/gcc/config/i386/cpuid.h +++ b/gcc/config/i386/cpuid.h @@ -243,6 +243,7 @@ pointer is non-null, then first four bytes of the signature (as found in ebx register) are returned in location pointed by sig. */ +__attribute__ ((target("general-regs-only"))) static __inline unsigned int __get_cpuid_max (unsigned int __ext, unsigned int *__sig) { @@ -298,6 +299,7 @@ __get_cpuid_max (unsigned int __ext, unsigned int *__sig) supported and returns 1 for valid cpuid information or 0 for unsupported cpuid leaf. All pointers are required to be non-null. */ +__attribute__ ((target("general-regs-only"))) static __inline int __get_cpuid (unsigned int __leaf, unsigned int *__eax, unsigned int *__ebx, @@ -315,6 +317,7 @@ __get_cpuid (unsigned int __leaf, /* Same as above, but sub-leaf can be specified. */ +__attribute__ ((target("general-regs-only"))) static __inline int __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf, unsigned int *__eax, unsigned int *__ebx, @@ -330,6 +333,7 @@ __get_cpuid_count (unsigned int __leaf, unsigned int __subleaf, return 1; } +__attribute__ ((target("general-regs-only"))) static __inline void __cpuidex (int __cpuid_info[4], int __leaf, int __subleaf) { diff --git a/gcc/testsuite/gcc.target/i386/avx512-check.h b/gcc/testsuite/gcc.target/i386/avx512-check.h index 0a377dba1d5..406faf8fe03 100644 --- a/gcc/testsuite/gcc.target/i386/avx512-check.h +++ b/gcc/testsuite/gcc.target/i386/avx512-check.h @@ -25,6 +25,7 @@ do_test (void) } #endif +__attribute__ ((target("general-regs-only"))) static int check_osxsave (void) { @@ -34,6 +35,7 @@ check_osxsave (void) return (ecx & bit_OSXSAVE) != 0; } +__attribute__ ((target("general-regs-only"))) int main () { -- 2.31.1