public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Mayshao-oc <Mayshao-oc@zhaoxin.com>, Uros Bizjak <ubizjak@gmail.com>
Cc: "Silvia Zhao(BJ-RD)" <SilviaZhao@zhaoxin.com>,
	TimHu-oc <TimHu-oc@zhaoxin.com>,
	"Cobe Chen(BJ-RD)" <CobeChen@zhaoxin.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"Hawk Wang(BJ-RD)" <HawkWang@zhaoxin.com>,
	"Louis Qi(BJ-RD)" <LouisQi@zhaoxin.com>,
	Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] [x86_64] Zhaoxin lujiazui enablement
Date: Tue, 25 Oct 2022 06:38:14 +0200	[thread overview]
Message-ID: <9263704e-b2f1-f21d-f888-a884547a0cf5@suse.cz> (raw)
In-Reply-To: <d429723ce0c848e4870b56521c67c66a@zhaoxin.com>

[-- Attachment #1: Type: text/plain, Size: 801 bytes --]

Hello.

I noticed this patch set which is kind of related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107364.

And I have a couple of questions:

1) I noticed you drop AVX and F16C features for the newly added "lujiazui". Why do you need it?
   I would expect these features would be properly detected by cpuid?

2) If you really need it, can you please test for me the attached patch? It should come up
   with a new function.

3) Have question about:

  else if (vendor == signature_CENTAUR_ebx && family < 0x07)
    cpu_model->__cpu_vendor = VENDOR_CENTAUR;
  else if (vendor == signature_SHANGHAI_ebx
		|| vendor == signature_CENTAUR_ebx)

Are there any signature_CENTAUR_ebx models with family == 0x7 ?
Similarly, are there any signature_SHANGHAI_ebx modes with family < 0x7 ?

Thanks,
Martin

[-- Attachment #2: 0001-i386-add-reset_cpu_feature.patch --]
[-- Type: text/x-patch, Size: 2440 bytes --]

From fa0bd99da8fd92b15a2cee55737a5962657da212 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 25 Oct 2022 06:28:44 +0200
Subject: [PATCH] i386: add reset_cpu_feature

gcc/ChangeLog:

	* common/config/i386/cpuinfo.h (has_cpu_feature): Add comment.
	(reset_cpu_feature): New.
	(get_zhaoxin_cpu): Use reset_cpu_feature.
---
 gcc/common/config/i386/cpuinfo.h | 38 +++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h
index d45451c5704..19ea7132fd5 100644
--- a/gcc/common/config/i386/cpuinfo.h
+++ b/gcc/common/config/i386/cpuinfo.h
@@ -76,6 +76,8 @@ has_cpu_feature (struct __processor_model *cpu_model,
     }
 }
 
+/* Save FEATURE to either CPU_MODEL or CPU_FEATURES2.  */
+
 static inline void
 set_cpu_feature (struct __processor_model *cpu_model,
 		 unsigned int *cpu_features2,
@@ -100,6 +102,32 @@ set_cpu_feature (struct __processor_model *cpu_model,
     }
 }
 
+/* Drop FEATURE from either CPU_MODEL or CPU_FEATURES2.  */
+
+static inline void
+reset_cpu_feature (struct __processor_model *cpu_model,
+		   unsigned int *cpu_features2,
+		   enum processor_features feature)
+{
+  unsigned index, offset;
+  unsigned f = feature;
+
+  if (f < 32)
+    {
+      /* The first 32 features.  */
+      cpu_model->__cpu_features[0] &= ~(1U << f);
+    }
+  else
+    {
+      /* The rest of features.  cpu_features2[i] contains features from
+	 (32 + i * 32) to (31 + 32 + i * 32), inclusively.  */
+      f -= 32;
+      index = f / 32;
+      offset = f % 32;
+      cpu_features2[index] &= ~(1U << offset);
+    }
+}
+
 /* Get the specific type of AMD CPU and return AMD CPU name.  Return
    NULL for unknown AMD CPU.  */
 
@@ -565,11 +593,11 @@ get_zhaoxin_cpu (struct __processor_model *cpu_model,
       cpu_model->__cpu_type = ZHAOXIN_FAM7H;
       if (model == 0x3b)
 	{
-	cpu = "lujiazui";
-	CHECK___builtin_cpu_is ("lujiazui");
-	cpu_model->__cpu_features[0] &= ~(1U <<(FEATURE_AVX & 31));
-	cpu_features2[0] &= ~(1U <<((FEATURE_F16C - 32) & 31));
-	cpu_model->__cpu_subtype = ZHAOXIN_FAM7H_LUJIAZUI;
+	  cpu = "lujiazui";
+	  CHECK___builtin_cpu_is ("lujiazui");
+	  reset_cpu_feature (cpu_model, cpu_features2, FEATURE_AVX);
+	  reset_cpu_feature (cpu_model, cpu_features2, FEATURE_F16C);
+	  cpu_model->__cpu_subtype = ZHAOXIN_FAM7H_LUJIAZUI;
 	}
       break;
     default:
-- 
2.38.0


  reply	other threads:[~2022-10-25  4:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25  2:08 MayShao
2022-03-27  9:15 ` Uros Bizjak
2022-03-28  7:25   ` Mayshao-oc
2022-10-25  4:38     ` Martin Liška [this message]
2022-10-26  9:06       ` Mayshao-oc
2022-10-26 10:46         ` Martin Liška
2022-10-27  9:09           ` Mayshao-oc
2022-10-27  9:11             ` Martin Liška
2022-05-17  3:15 [PATCH] [x86_64]: " mayshao
2022-05-17  6:23 ` Richard Biener
2022-05-17  9:33   ` Mayshao-oc
2022-05-22 16:41     ` Uros Bizjak
2022-05-23 10:44       ` Mayshao-oc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9263704e-b2f1-f21d-f888-a884547a0cf5@suse.cz \
    --to=mliska@suse.cz \
    --cc=CobeChen@zhaoxin.com \
    --cc=HawkWang@zhaoxin.com \
    --cc=LouisQi@zhaoxin.com \
    --cc=Mayshao-oc@zhaoxin.com \
    --cc=SilviaZhao@zhaoxin.com \
    --cc=TimHu-oc@zhaoxin.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).