From patchwork Thu Feb 9 12:11:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 54902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297613wrn; Thu, 9 Feb 2023 04:12:42 -0800 (PST) X-Google-Smtp-Source: AK7set/h2vh7x2xxF00g8ZT6zx5xpTdgrlLJiyG/E446++OQRIwE0o1EBAL3GLAA2n9SZXP/Tofh X-Received: by 2002:a50:d744:0:b0:4aa:a4dd:aab2 with SMTP id i4-20020a50d744000000b004aaa4ddaab2mr11150845edj.11.1675944762430; Thu, 09 Feb 2023 04:12:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675944762; cv=none; d=google.com; s=arc-20160816; b=HHKG62FjV5mh1/HNuTsPMCzEKnXoGXUXgDe/z1jw+zQ3tRF3udy/w5jugkp+T2xRpn mk/gbeWacMVvoiQgZoKTAxWkQABzBRL31xsWpbGjNcg/C2GwRyRMDHTdnT2DmjuzYHoO +i7wjudh0USGxVFco4H0vYiL6EqH1KT1kUmrN/1oiIrZlvcnOsPUjqDXpQvFNoVMeXLi qV18IWR+r8pNCdAgj5eMFv+7TEN5lskvLh7gcAUqHE0mJD9znvTMVQ66/dVuexKJUZnA 82mzzZt7KkOhwd/n0KF730d0NDTDYqFpwPBxxahp8vwX9BTNU8RhiQsLbE4qdLaLbJc6 r5aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=2Cxbwqgo6S7gPvV9QiSP3uenpAWAlfBjz2fIkiK9bew=; b=yBXq2sX6q52GC3pllBkk3syyAbRxPQl9s8OJ60YqtTNwG6PlKm0G3q1g5xJ4Xg+o+G bmW1BoMzQ240wVgflQMzG0UY+3IPtX9Jvn0nk2Ai+c+QB0P6mBaR73WT0WGDnFoFI1Mj uN/4vTXUg1eu0EMdq9E3I0G2lOGxfs4IQQr9AsXVE19wlwRW6QeWFy64MJdlvnxmDvp/ kXGN2rVqHM3UfeoZ/vn8/a+LRw9+cgoTU9ehyMVchiaJ6nWUaUviP38IFEcZEUpn1Mwk uNNfV9a9S9ute3z3zux573ZieuwQilbL2RKtBso9VzjXTP6DiwpKZEWYXioMJTUK3k3J 4k2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RuBMsCy6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id l24-20020aa7d958000000b004aaabc46b59si2273038eds.628.2023.02.09.04.12.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 04:12:42 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RuBMsCy6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 711283858409 for ; Thu, 9 Feb 2023 12:12:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 711283858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675944761; bh=2Cxbwqgo6S7gPvV9QiSP3uenpAWAlfBjz2fIkiK9bew=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=RuBMsCy6azh4ixVkOkB1EaE8PcD5it5/ubs4SqbRB+jmhyhfhau6VfuXpL4FqAlnr RJtCghCu3s3l7Za303jqkhaQAdGQ3yJMte7XS9N7xQ5grkvHben6UhgyWD5Bg7m6EQ kcd32kMAbLtQglROrZUJMdSRkWuIW/4Op6SbmnMI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 3719D3858C60 for ; Thu, 9 Feb 2023 12:11:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3719D3858C60 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-596-vrbynsHkOOy0eaDd2uAEcA-1; Thu, 09 Feb 2023 07:11:57 -0500 X-MC-Unique: vrbynsHkOOy0eaDd2uAEcA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7F0C21C0418C; Thu, 9 Feb 2023 12:11:57 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36F1B18EC1; Thu, 9 Feb 2023 12:11:57 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 319CBnsi1928683 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 9 Feb 2023 13:11:50 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 319CBmnm1928682; Thu, 9 Feb 2023 13:11:48 +0100 Date: Thu, 9 Feb 2023 13:11:48 +0100 To: Uros Bizjak , "H.J. Lu" Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Call get_available_features for all CPUs with max_level >= 1 [PR100758] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757355455261451771?= X-GMAIL-MSGID: =?utf-8?q?1757355455261451771?= Hi! get_available_features doesn't depend on cpu_model2->__cpu_{family,model} and just sets stuff up based on CPUID leaf 1, or some extended ones, so I wonder why are we calling it separately for Intel, AMD and Zhaoxin and not for all other CPUs too? I think various programs in the wild which aren't using __builtin_cpu_{is,supports} just check the various CPUID leafs and query bits in there, without blacklisting unknown CPU vendors, so I think even __builtin_cpu_supports ("sse2") etc. should be reliable if those VENDOR_{CENTAUR,CYRIX,NSC,OTHER} CPUs set those bits in CPUID leaf 1 or some extended ones. Calling it for all CPUs also means it can be inlined because there will be just a single caller. I will test on Intel but can't test it on non-Intel (or with some extra effort on AMD; for both of those arches it should be really no change in behavior). Thoughts on this? 2023-02-09 Jakub Jelinek PR target/100758 * common/config/i386/cpuinfo.h (get_zhaoxin_cpu): Formatting fixes. (cpu_indicator_init): Call get_available_features for all CPUs with max_level >= 1, rather than just Intel, AMD or Zhaoxin. Formatting fixes. Jakub --- gcc/common/config/i386/cpuinfo.h.jj 2023-01-16 11:52:15.910736614 +0100 +++ gcc/common/config/i386/cpuinfo.h 2023-02-09 12:51:23.539470140 +0100 @@ -601,8 +601,8 @@ get_intel_cpu (struct __processor_model static inline const char * get_zhaoxin_cpu (struct __processor_model *cpu_model, - struct __processor_model2 *cpu_model2, - unsigned int *cpu_features2) + struct __processor_model2 *cpu_model2, + unsigned int *cpu_features2) { const char *cpu = NULL; unsigned int family = cpu_model2->__cpu_family; @@ -1016,6 +1016,10 @@ cpu_indicator_init (struct __processor_m extended_model = (eax >> 12) & 0xf0; extended_family = (eax >> 20) & 0xff; + /* Find available features. */ + get_available_features (cpu_model, cpu_model2, cpu_features2, + ecx, edx); + if (vendor == signature_INTEL_ebx) { /* Adjust model and family for Intel CPUS. */ @@ -1030,9 +1034,6 @@ cpu_indicator_init (struct __processor_m cpu_model2->__cpu_family = family; cpu_model2->__cpu_model = model; - /* Find available features. */ - get_available_features (cpu_model, cpu_model2, cpu_features2, - ecx, edx); /* Get CPU type. */ get_intel_cpu (cpu_model, cpu_model2, cpu_features2); cpu_model->__cpu_vendor = VENDOR_INTEL; @@ -1049,9 +1050,6 @@ cpu_indicator_init (struct __processor_m cpu_model2->__cpu_family = family; cpu_model2->__cpu_model = model; - /* Find available features. */ - get_available_features (cpu_model, cpu_model2, cpu_features2, - ecx, edx); /* Get CPU type. */ get_amd_cpu (cpu_model, cpu_model2, cpu_features2); cpu_model->__cpu_vendor = VENDOR_AMD; @@ -1059,22 +1057,17 @@ cpu_indicator_init (struct __processor_m else if (vendor == signature_CENTAUR_ebx && family < 0x07) cpu_model->__cpu_vendor = VENDOR_CENTAUR; else if (vendor == signature_SHANGHAI_ebx - || vendor == signature_CENTAUR_ebx) + || vendor == signature_CENTAUR_ebx) { /* Adjust model and family for ZHAOXIN CPUS. */ if (family == 0x07) - { - model += extended_model; - } + model += extended_model; cpu_model2->__cpu_family = family; cpu_model2->__cpu_model = model; - /* Find available features. */ - get_available_features (cpu_model, cpu_model2, cpu_features2, - ecx, edx); /* Get CPU type. */ - get_zhaoxin_cpu (cpu_model, cpu_model2,cpu_features2); + get_zhaoxin_cpu (cpu_model, cpu_model2, cpu_features2); cpu_model->__cpu_vendor = VENDOR_ZHAOXIN; } else if (vendor == signature_CYRIX_ebx)