From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675944718; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=2Cxbwqgo6S7gPvV9QiSP3uenpAWAlfBjz2fIkiK9bew=; b=SZhdmCdTuL4in98GY08+vbhFkS8SNKSYoahqHNfcoVkyiAmZZ7Qn3uBgo+MyQktsCO4Unr be7YzyH8QxnPhJZucDgj9BCoSgy+bKkscBgPScBEh0cj73Icws6iefbX9AYSBhYH5CYW+t +GRYtJ5jo5dPC2S73rGgJl1cYtFU0qA= 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 From: Jakub Jelinek 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: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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) Jakub