x86: Remove brand ID check for Intel processors

Message ID 20200624150156.349994-1-hjl.tools@gmail.com
State New
Headers show
Series
  • x86: Remove brand ID check for Intel processors
Related show

Commit Message

Jakub Jelinek via Gcc-patches June 24, 2020, 3:01 p.m.
Brand ID was a feature that briefly existed in some Pentium III and
Pentium 4 CPUs.  The CPUs that had non-zero brand ID still have had
valid family/model.  Brand ID just gives a marketing name for the CPU.
Remove the extra code for brand ID check.

gcc/

	PR target/95660
	* common/config/i386/cpuinfo.h (get_intel_cpu): Remove brand_id.
	(cpu_indicator_init): Likewise.
	* config/i386/driver-i386.c (host_detect_local_cpu): Updated.

gcc/testsuite/

	PR target/95660
	* gcc.target/i386/builtin_target.c (check_detailed): Updated.
---
 gcc/common/config/i386/cpuinfo.h               | 12 +++++-------
 gcc/config/i386/driver-i386.c                  |  2 +-
 gcc/testsuite/gcc.target/i386/builtin_target.c |  2 +-
 3 files changed, 7 insertions(+), 9 deletions(-)

-- 
2.26.2

Comments

Jakub Jelinek via Gcc-patches June 24, 2020, 3:06 p.m. | #1
On Wed, Jun 24, 2020 at 5:01 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> Brand ID was a feature that briefly existed in some Pentium III and

> Pentium 4 CPUs.  The CPUs that had non-zero brand ID still have had

> valid family/model.  Brand ID just gives a marketing name for the CPU.

> Remove the extra code for brand ID check.

>

> gcc/

>

>         PR target/95660

>         * common/config/i386/cpuinfo.h (get_intel_cpu): Remove brand_id.

>         (cpu_indicator_init): Likewise.

>         * config/i386/driver-i386.c (host_detect_local_cpu): Updated.

>

> gcc/testsuite/

>

>         PR target/95660

>         * gcc.target/i386/builtin_target.c (check_detailed): Updated.


LGTM.

Thanks,
Uros.

> ---

>  gcc/common/config/i386/cpuinfo.h               | 12 +++++-------

>  gcc/config/i386/driver-i386.c                  |  2 +-

>  gcc/testsuite/gcc.target/i386/builtin_target.c |  2 +-

>  3 files changed, 7 insertions(+), 9 deletions(-)

>

> diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h

> index 27b7b4d8581..3eda53240f6 100644

> --- a/gcc/common/config/i386/cpuinfo.h

> +++ b/gcc/common/config/i386/cpuinfo.h

> @@ -254,13 +254,12 @@ get_amd_cpu (struct __processor_model *cpu_model,

>  static inline const char *

>  get_intel_cpu (struct __processor_model *cpu_model,

>                struct __processor_model2 *cpu_model2,

> -              unsigned int *cpu_features2,

> -              unsigned int brand_id)

> +              unsigned int *cpu_features2)

>  {

>    const char *cpu = NULL;

>

> -  /* Parse family and model only for brand ID 0 and model 6. */

> -  if (brand_id != 0 || cpu_model2->__cpu_family != 0x6)

> +  /* Parse family and model only for model 6. */

> +  if (cpu_model2->__cpu_family != 0x6)

>      return cpu;

>

>    switch (cpu_model2->__cpu_model)

> @@ -758,7 +757,7 @@ cpu_indicator_init (struct __processor_model *cpu_model,

>

>    int max_level;

>    unsigned int vendor;

> -  unsigned int model, family, brand_id;

> +  unsigned int model, family;

>    unsigned int extended_model, extended_family;

>

>    /* This function needs to run just once.  */

> @@ -791,7 +790,6 @@ cpu_indicator_init (struct __processor_model *cpu_model,

>

>    model = (eax >> 4) & 0x0f;

>    family = (eax >> 8) & 0x0f;

> -  brand_id = ebx & 0xff;

>    extended_model = (eax >> 12) & 0xf0;

>    extended_family = (eax >> 20) & 0xff;

>

> @@ -813,7 +811,7 @@ cpu_indicator_init (struct __processor_model *cpu_model,

>        get_available_features (cpu_model, cpu_model2, cpu_features2,

>                               ecx, edx);

>        /* Get CPU type.  */

> -      get_intel_cpu (cpu_model, cpu_model2, cpu_features2, brand_id);

> +      get_intel_cpu (cpu_model, cpu_model2, cpu_features2);

>        cpu_model->__cpu_vendor = VENDOR_INTEL;

>      }

>    else if (vendor == signature_AMD_ebx)

> diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c

> index e9e4d6ed023..6da2a15c1b0 100644

> --- a/gcc/config/i386/driver-i386.c

> +++ b/gcc/config/i386/driver-i386.c

> @@ -555,7 +555,7 @@ const char *host_detect_local_cpu (int argc, const char **argv)

>         cpu = "pentium";

>        break;

>      case PROCESSOR_PENTIUMPRO:

> -      cpu = get_intel_cpu (&cpu_model, &cpu_model2, cpu_features2, 0);

> +      cpu = get_intel_cpu (&cpu_model, &cpu_model2, cpu_features2);

>        if (cpu == NULL)

>         {

>           if (arch)

> diff --git a/gcc/testsuite/gcc.target/i386/builtin_target.c b/gcc/testsuite/gcc.target/i386/builtin_target.c

> index e87f262a775..aa9680544d8 100644

> --- a/gcc/testsuite/gcc.target/i386/builtin_target.c

> +++ b/gcc/testsuite/gcc.target/i386/builtin_target.c

> @@ -46,7 +46,7 @@ check_detailed ()

>      {

>      case VENDOR_INTEL:

>        assert (__builtin_cpu_is ("intel"));

> -      get_intel_cpu (&cpu_model, &cpu_model2, cpu_features2, 0);

> +      get_intel_cpu (&cpu_model, &cpu_model2, cpu_features2);

>        break;

>      case VENDOR_AMD:

>        assert (__builtin_cpu_is ("amd"));

> --

> 2.26.2

>

Patch

diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h
index 27b7b4d8581..3eda53240f6 100644
--- a/gcc/common/config/i386/cpuinfo.h
+++ b/gcc/common/config/i386/cpuinfo.h
@@ -254,13 +254,12 @@  get_amd_cpu (struct __processor_model *cpu_model,
 static inline const char *
 get_intel_cpu (struct __processor_model *cpu_model,
 	       struct __processor_model2 *cpu_model2,
-	       unsigned int *cpu_features2,
-	       unsigned int brand_id)
+	       unsigned int *cpu_features2)
 {
   const char *cpu = NULL;
 
-  /* Parse family and model only for brand ID 0 and model 6. */
-  if (brand_id != 0 || cpu_model2->__cpu_family != 0x6)
+  /* Parse family and model only for model 6. */
+  if (cpu_model2->__cpu_family != 0x6)
     return cpu;
 
   switch (cpu_model2->__cpu_model)
@@ -758,7 +757,7 @@  cpu_indicator_init (struct __processor_model *cpu_model,
 
   int max_level;
   unsigned int vendor;
-  unsigned int model, family, brand_id;
+  unsigned int model, family;
   unsigned int extended_model, extended_family;
 
   /* This function needs to run just once.  */
@@ -791,7 +790,6 @@  cpu_indicator_init (struct __processor_model *cpu_model,
 
   model = (eax >> 4) & 0x0f;
   family = (eax >> 8) & 0x0f;
-  brand_id = ebx & 0xff;
   extended_model = (eax >> 12) & 0xf0;
   extended_family = (eax >> 20) & 0xff;
 
@@ -813,7 +811,7 @@  cpu_indicator_init (struct __processor_model *cpu_model,
       get_available_features (cpu_model, cpu_model2, cpu_features2,
 			      ecx, edx);
       /* Get CPU type.  */
-      get_intel_cpu (cpu_model, cpu_model2, cpu_features2, brand_id);
+      get_intel_cpu (cpu_model, cpu_model2, cpu_features2);
       cpu_model->__cpu_vendor = VENDOR_INTEL;
     }
   else if (vendor == signature_AMD_ebx)
diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c
index e9e4d6ed023..6da2a15c1b0 100644
--- a/gcc/config/i386/driver-i386.c
+++ b/gcc/config/i386/driver-i386.c
@@ -555,7 +555,7 @@  const char *host_detect_local_cpu (int argc, const char **argv)
 	cpu = "pentium";
       break;
     case PROCESSOR_PENTIUMPRO:
-      cpu = get_intel_cpu (&cpu_model, &cpu_model2, cpu_features2, 0);
+      cpu = get_intel_cpu (&cpu_model, &cpu_model2, cpu_features2);
       if (cpu == NULL)
 	{
 	  if (arch)
diff --git a/gcc/testsuite/gcc.target/i386/builtin_target.c b/gcc/testsuite/gcc.target/i386/builtin_target.c
index e87f262a775..aa9680544d8 100644
--- a/gcc/testsuite/gcc.target/i386/builtin_target.c
+++ b/gcc/testsuite/gcc.target/i386/builtin_target.c
@@ -46,7 +46,7 @@  check_detailed ()
     {
     case VENDOR_INTEL:
       assert (__builtin_cpu_is ("intel"));
-      get_intel_cpu (&cpu_model, &cpu_model2, cpu_features2, 0);
+      get_intel_cpu (&cpu_model, &cpu_model2, cpu_features2);
       break;
     case VENDOR_AMD:
       assert (__builtin_cpu_is ("amd"));