From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by sourceware.org (Postfix) with ESMTPS id 19C9D3858C50 for ; Thu, 9 Feb 2023 15:31:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 19C9D3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-169ba826189so3005919fac.2 for ; Thu, 09 Feb 2023 07:31:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OSxlH/uae7pdCacxwzZr/3dxFbFe/+d1u9a/SBQQpNM=; b=TXBRJ7kg5jhoRCrTFGjQmT/Lv9PX/ibreDFGCSYh55ywGlKZxVZ6HZUiunHzSaapKh iNtDQjUSn2UIOafwLY4MDf+4d4ZDlQonitQR25XC3WIuHvwIsPFjAA+WdmwwXVBoIRy2 1cwfvvD1TclrXDBRpV5gHNGbw5Wo+nQXGWRAalj2Gc+YxpmZTqi3ZtJ1Uq7mRaNv0iCD EkbKbhll3JjzK+wpotOl3sz3x3ec/go0YAR7j8k9/cj5h1m1CPeet+CqAMS5kNVKCbmd m8s0F4RdoXxeXe0TqX5FO41gYed1Ese6u62RV4+mMFzY+AEYiu0bIP4wonCLzlMlMffR f6lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OSxlH/uae7pdCacxwzZr/3dxFbFe/+d1u9a/SBQQpNM=; b=gN3Cn26a+cv/ed0VypoWG80eWMHV0kdAGftBnxoF+lz72JaL9Fatj1TaCeGsyyA3u6 RdF3q5gbxQOezlrnJJjML3fjJ18gJ8eHqqHlrKFPX+Xmln/QzCTAAcf194NW215RcuD4 PjdK4U2NisTCye44C8OLYEL1II2CsSoSpjIXRBlfFrv18GpecxqYQU6+XI1rt+D0XyYk vdf9wGBHjE542EG1gg3J966HcNTZLcZmtvBwDX2kVSKamDRPszqGnJJlggh/X1kOKRwv XoyHTq/mGW9cV5zi38Y0ObbHt/xLIVRaqDmyw/QCmSDuzBBW6c9uS7HqCt2QRQx7mGEM ImDQ== X-Gm-Message-State: AO0yUKWeAVj/cMy072cY6zVGqRFguDd3FuiKeB21DvQc3+BisRujXskA lVNm2bepQYv6+K45WF7vgto7REv0EpdOOYguXI8= X-Google-Smtp-Source: AK7set8aUNHYiCO/86rffWW2g1FMWrukpS5lek9QRdfI6eNlsgJM54YMTJ+AJAH+stsQBFzpqyh4AwGSCqszj0EGq5A= X-Received: by 2002:a05:6870:10cf:b0:16a:839d:8ce5 with SMTP id 15-20020a05687010cf00b0016a839d8ce5mr1459383oar.298.1675956689176; Thu, 09 Feb 2023 07:31:29 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: "H.J. Lu" Date: Thu, 9 Feb 2023 07:30:52 -0800 Message-ID: Subject: Re: [PATCH] i386: Call get_available_features for all CPUs with max_level >= 1 [PR100758] To: Jakub Jelinek Cc: Uros Bizjak , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3016.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: On Thu, Feb 9, 2023 at 4:12 AM Jakub Jelinek wrote: > > 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? No objection here. It just isn't easy to verify CPUID behavior on other processors. Thanks. > 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 > -- H.J.