]> sourceware.org Git - glibc.git/commitdiff
x86: Set Prefer_No_VZEROUPPER and add Prefer_AVX2_STRCMP
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 26 Feb 2021 13:36:59 +0000 (05:36 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 29 Mar 2021 14:40:17 +0000 (07:40 -0700)
1. Set Prefer_No_VZEROUPPER if RTM is usable to avoid RTM abort triggered
by VZEROUPPER inside a transactionally executing RTM region.
2. Since to compare 2 32-byte strings, 256-bit EVEX strcmp requires 2
loads, 3 VPCMPs and 2 KORDs while AVX2 strcmp requires 1 load, 2 VPCMPEQs,
1 VPMINU and 1 VPMOVMSKB, AVX2 strcmp is faster than EVEX strcmp.  Add
Prefer_AVX2_STRCMP to prefer AVX2 strcmp family functions.

sysdeps/x86/cpu-features.c
sysdeps/x86/cpu-tunables.c
sysdeps/x86/include/cpu-features-preferred_feature_index_1.def

index e99e67f34d81de4027d3feb3d8592657cd01fe61..81275dbdfa339e8be380d9e1bdb988a6fa34b6f2 100644 (file)
@@ -531,8 +531,24 @@ init_cpu_features (struct cpu_features *cpu_features)
        cpu_features->preferred[index_arch_Prefer_No_VZEROUPPER]
          |= bit_arch_Prefer_No_VZEROUPPER;
       else
-       cpu_features->preferred[index_arch_Prefer_No_AVX512]
-         |= bit_arch_Prefer_No_AVX512;
+       {
+         cpu_features->preferred[index_arch_Prefer_No_AVX512]
+           |= bit_arch_Prefer_No_AVX512;
+
+         /* Avoid RTM abort triggered by VZEROUPPER inside a
+            transactionally executing RTM region.  */
+         if (CPU_FEATURE_USABLE_P (cpu_features, RTM))
+           cpu_features->preferred[index_arch_Prefer_No_VZEROUPPER]
+             |= bit_arch_Prefer_No_VZEROUPPER;
+
+         /* Since to compare 2 32-byte strings, 256-bit EVEX strcmp
+            requires 2 loads, 3 VPCMPs and 2 KORDs while AVX2 strcmp
+            requires 1 load, 2 VPCMPEQs, 1 VPMINU and 1 VPMOVMSKB,
+            AVX2 strcmp is faster than EVEX strcmp.  */
+         if (CPU_FEATURE_USABLE_P (cpu_features, AVX2))
+           cpu_features->preferred[index_arch_Prefer_AVX2_STRCMP]
+             |= bit_arch_Prefer_AVX2_STRCMP;
+       }
     }
   /* This spells out "AuthenticAMD" or "HygonGenuine".  */
   else if ((ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65)
index 61b05e5b1d56179470d03db8933e5d48257867fe..00fe5045eb56eb076d08f55068692bcf1a1cd2c7 100644 (file)
@@ -239,6 +239,8 @@ TUNABLE_CALLBACK (set_hwcaps) (tunable_val_t *valp)
              CHECK_GLIBC_IFUNC_PREFERRED_BOTH (n, cpu_features,
                                                Fast_Copy_Backward,
                                                disable, 18);
+             CHECK_GLIBC_IFUNC_PREFERRED_NEED_BOTH
+               (n, cpu_features, Prefer_AVX2_STRCMP, AVX2, disable, 18);
            }
          break;
        case 19:
index 06af1a8dd5c6c2b4dc5bd70ff03996717b4158d1..133aab19f1e83cedf3ea153c692390114f38969e 100644 (file)
@@ -32,3 +32,4 @@ BIT (Prefer_ERMS)
 BIT (Prefer_No_AVX512)
 BIT (MathVec_Prefer_No_AVX512)
 BIT (Prefer_FSRM)
+BIT (Prefer_AVX2_STRCMP)
This page took 0.044776 seconds and 5 git commands to generate.