diff mbox series

X86: Fix feature check for HRESET/AVX_VNNI/UINTR

Message ID CA+OydWm0QnMqG_DeGeKqZQTRTnpm6D3y83TB1sqjPB1ex7e7Jg@mail.gmail.com
State New
Headers show
Series X86: Fix feature check for HRESET/AVX_VNNI/UINTR | expand

Commit Message

Hongyu Wang Dec. 10, 2020, 3:37 a.m. UTC
Hi,

This patch is a simple fix for HRESET/AVX_VNNI/UINTR feature detect is
put wrongly under avx_512usable.

Bootstrap and tested on x86-64-linux, OK for trunk?

gcc/ChangeLog:
    * common/config/i386/cpuinfo.h (get_available_features):
    Move check for HRESET/AVX_VNNI/UINTR out of avx512_usable.
---
 gcc/common/config/i386/cpuinfo.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Uros Bizjak Dec. 10, 2020, 7:15 a.m. UTC | #1
On Thu, Dec 10, 2020 at 4:42 AM Hongyu Wang <wwwhhhyyy333@gmail.com> wrote:
>
> Hi,
>
> This patch is a simple fix for HRESET/AVX_VNNI/UINTR feature detect is
> put wrongly under avx_512usable.
>
> Bootstrap and tested on x86-64-linux, OK for trunk?
>
> gcc/ChangeLog:
>     * common/config/i386/cpuinfo.h (get_available_features):
>     Move check for HRESET/AVX_VNNI/UINTR out of avx512_usable.
> ---
>  gcc/common/config/i386/cpuinfo.h | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h
> index 4f1ab636807..19de63fe7ac 100644
> --- a/gcc/common/config/i386/cpuinfo.h
> +++ b/gcc/common/config/i386/cpuinfo.h
> @@ -686,6 +686,8 @@ get_available_features (struct __processor_model *cpu_model,
>        if (edx & bit_AMX_BF16)
>          set_feature (FEATURE_AMX_BF16);
>      }
> +      if (edx & bit_UINTR)
> +    set_feature (FEATURE_UINTR);
>        if (ecx & bit_KL)
>      has_kl = 1;
>        if (avx512_usable)
> @@ -722,17 +724,19 @@ get_available_features (struct __processor_model
> *cpu_model,
>          set_feature (FEATURE_AVX5124FMAPS);
>        if (edx & bit_AVX512VP2INTERSECT)
>          set_feature (FEATURE_AVX512VP2INTERSECT);
> -      if (edx & bit_UINTR)
> -        set_feature (FEATURE_UINTR);
>
>        __cpuid_count (7, 1, eax, ebx, ecx, edx);
>        if (eax & bit_AVX512BF16)
>          set_feature (FEATURE_AVX512BF16);
> -      if (eax & bit_HRESET)
> -        set_feature (FEATURE_HRESET);
> +    }
> +
> +      __cpuid_count (7, 1, eax, ebx, ecx, edx);

Please better move __cpuid_count (7, 1, ...) in its own place, as is
done in the attached patch (that also groups a couple of features
together).

OK with the above change.

Thanks,
Uros.

> +      if (eax & bit_HRESET)
> +    set_feature (FEATURE_HRESET);
> +      if (avx_usable)
> +    {
>        if (eax & bit_AVXVNNI)
>          set_feature (FEATURE_AVXVNNI);
> -
>      }
>      }
>
> --
>
> --
> Regards,
>
> Hongyu, Wang
diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h
index 4f1ab636807..a3372fc4ecf 100644
--- a/gcc/common/config/i386/cpuinfo.h
+++ b/gcc/common/config/i386/cpuinfo.h
@@ -669,6 +669,8 @@ get_available_features (struct __processor_model *cpu_model,
 	set_feature (FEATURE_WAITPKG);
       if (ecx & bit_SHSTK)
 	set_feature (FEATURE_SHSTK);
+      if (ecx & bit_KL)
+	has_kl = 1;
       if (edx & bit_SERIALIZE)
 	set_feature (FEATURE_SERIALIZE);
       if (edx & bit_TSXLDTRK)
@@ -677,6 +679,8 @@ get_available_features (struct __processor_model *cpu_model,
 	set_feature (FEATURE_PCONFIG);
       if (edx & bit_IBT)
 	set_feature (FEATURE_IBT);
+      if (edx & bit_UINTR)
+	set_feature (FEATURE_UINTR);
       if (amx_usable)
 	{
 	  if (edx & bit_AMX_TILE)
@@ -686,8 +690,6 @@ get_available_features (struct __processor_model *cpu_model,
 	  if (edx & bit_AMX_BF16)
 	    set_feature (FEATURE_AMX_BF16);
 	}
-      if (ecx & bit_KL)
-	has_kl = 1;
       if (avx512_usable)
 	{
 	  if (ebx & bit_AVX512F)
@@ -722,17 +724,20 @@ get_available_features (struct __processor_model *cpu_model,
 	    set_feature (FEATURE_AVX5124FMAPS);
 	  if (edx & bit_AVX512VP2INTERSECT)
 	    set_feature (FEATURE_AVX512VP2INTERSECT);
-	  if (edx & bit_UINTR)
-	    set_feature (FEATURE_UINTR);
+	}
 
-	  __cpuid_count (7, 1, eax, ebx, ecx, edx);
-	  if (eax & bit_AVX512BF16)
-	    set_feature (FEATURE_AVX512BF16);
-	  if (eax & bit_HRESET)
-	    set_feature (FEATURE_HRESET);
+      __cpuid_count (7, 1, eax, ebx, ecx, edx);
+      if (eax & bit_HRESET)
+	set_feature (FEATURE_HRESET);
+      if (avx_usable)
+	{
 	  if (eax & bit_AVXVNNI)
 	    set_feature (FEATURE_AVXVNNI);
-
+	}
+      if (avx512_usable)
+	{
+	  if (eax & bit_AVX512BF16)
+	    set_feature (FEATURE_AVX512BF16);
 	}
     }
diff mbox series

Patch

diff --git a/gcc/common/config/i386/cpuinfo.h b/gcc/common/config/i386/cpuinfo.h
index 4f1ab636807..19de63fe7ac 100644
--- a/gcc/common/config/i386/cpuinfo.h
+++ b/gcc/common/config/i386/cpuinfo.h
@@ -686,6 +686,8 @@  get_available_features (struct __processor_model *cpu_model,
       if (edx & bit_AMX_BF16)
         set_feature (FEATURE_AMX_BF16);
     }
+      if (edx & bit_UINTR)
+    set_feature (FEATURE_UINTR);
       if (ecx & bit_KL)
     has_kl = 1;
       if (avx512_usable)
@@ -722,17 +724,19 @@  get_available_features (struct __processor_model
*cpu_model,
         set_feature (FEATURE_AVX5124FMAPS);
       if (edx & bit_AVX512VP2INTERSECT)
         set_feature (FEATURE_AVX512VP2INTERSECT);
-      if (edx & bit_UINTR)
-        set_feature (FEATURE_UINTR);

       __cpuid_count (7, 1, eax, ebx, ecx, edx);
       if (eax & bit_AVX512BF16)
         set_feature (FEATURE_AVX512BF16);
-      if (eax & bit_HRESET)
-        set_feature (FEATURE_HRESET);
+    }
+
+      __cpuid_count (7, 1, eax, ebx, ecx, edx);
+      if (eax & bit_HRESET)
+    set_feature (FEATURE_HRESET);
+      if (avx_usable)
+    {
       if (eax & bit_AVXVNNI)
         set_feature (FEATURE_AVXVNNI);
-
     }
     }