From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 1B4B53858C74; Thu, 9 Feb 2023 16:45:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B4B53858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675961155; bh=qTk6qfE50HiKepm4UKSatv4LKyGMS/6D3/DYBdL7U2o=; h=From:To:Subject:Date:From; b=jihG6ValyItOV1z1Q1yEwei8g8HoFCHNRzFWAOJ7fxlrCnzcjlOAkX2/LUCCd2GGd r9aJejfFYEjEPlghTBhGjJ2CYpUUwLSLaUeHa/laHRV5yTj74mjh7cg6/L789gLs6l ktBpEjk8PRqwf3CobDFqo7fbHnr5OESlIl/sTsRI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5759] i386: Call get_available_features for all CPUs with max_level >= 1 [PR100758] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: bcca64d70ce91e29717fb70cff252639df6902be X-Git-Newrev: b24e9c083093a9e1b1007933a184c02f7ff058db Message-Id: <20230209164555.1B4B53858C74@sourceware.org> Date: Thu, 9 Feb 2023 16:45:55 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b24e9c083093a9e1b1007933a184c02f7ff058db commit r13-5759-gb24e9c083093a9e1b1007933a184c02f7ff058db Author: Jakub Jelinek Date: Thu Feb 9 17:43:19 2023 +0100 i386: Call get_available_features for all CPUs with max_level >= 1 [PR100758] 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 have tested it on Intel and Martin tested it on AMD, but can't test it on non-Intel/AMD; for Intel/AMD/Zhaoxin it should be really no change in behavior. 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. Diff: --- gcc/common/config/i386/cpuinfo.h | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h index 36955a5673b..5bde0cddb24 100644 --- a/gcc/common/config/i386/cpuinfo.h +++ b/gcc/common/config/i386/cpuinfo.h @@ -601,8 +601,8 @@ get_intel_cpu (struct __processor_model *cpu_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_model *cpu_model, 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_model *cpu_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_intel_cpu (cpu_model, cpu_model2, cpu_features2); cpu_model->__cpu_vendor = VENDOR_INTEL; @@ -1049,9 +1050,6 @@ cpu_indicator_init (struct __processor_model *cpu_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_amd_cpu (cpu_model, cpu_model2, cpu_features2); cpu_model->__cpu_vendor = VENDOR_AMD; @@ -1059,22 +1057,17 @@ cpu_indicator_init (struct __processor_model *cpu_model, 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)