[gcc11,backport] i386: Call get_available_features for all CPUs with max_level >= 1 [PR100758]

Message ID 20230309021627.19767-1-mayshao-oc@zhaoxin.com
State Unresolved
Headers
Series [gcc11,backport] i386: Call get_available_features for all CPUs with max_level >= 1 [PR100758] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Mayshao-oc March 9, 2023, 2:16 a.m. UTC
  Hi Jakub:
  This is backport of the fix for PR target/100758 from mainline to the gcc11 release branch. Because the bug still exists in gcc11 on Zhaoxin platform, and it will incur ISA feature detection failure, we want to fix it as the mainline.This patch has been retested against the gcc11 branch on Intel,Amd,Zhaoxin with make bootstrap and make -k check without failure. Ok for the gcc11 branch?

BR
Mayshao

gcc/ChangeLog:
	PR target/100758
	* common/config/i386/cpuinfo.h (cpu_indicator_init): Call get_available_features
	for all CPUs with max_level >= 1, rather than just Intel, AMD.
---
 gcc/common/config/i386/cpuinfo.h | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
  

Patch

diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h
index 18ff71ac5ad..00b5eee21d4 100644
--- a/gcc/common/config/i386/cpuinfo.h
+++ b/gcc/common/config/i386/cpuinfo.h
@@ -882,6 +882,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. */
@@ -896,9 +900,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;
@@ -915,9 +916,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;