190885
From 6b2150da7cac8cccdcf1de189b3ab7cbd6519535 Mon Sep 17 00:00:00 2001
190885
From: "H.J. Lu" <hjl.tools@gmail.com>
190885
Date: Mon, 19 Apr 2021 10:45:07 -0700
190885
Subject: [PATCH] x86-64: Require BMI2 for strchr-avx2.S
190885
190885
Since strchr-avx2.S updated by
190885
190885
commit 1f745ecc2109890886b161d4791e1406fdfc29b8
190885
Author: noah <goldstein.w.n@gmail.com>
190885
Date:   Wed Feb 3 00:38:59 2021 -0500
190885
190885
    x86-64: Refactor and improve performance of strchr-avx2.S
190885
190885
uses sarx:
190885
190885
c4 e2 72 f7 c0       	sarx   %ecx,%eax,%eax
190885
190885
for strchr-avx2 family functions, require BMI2 in ifunc-impl-list.c and
190885
ifunc-avx2.h.
190885
190885
(cherry picked from commit 83c5b368226c34a2f0a5287df40fc290b2b34359)
190885
---
190885
 sysdeps/x86_64/multiarch/ifunc-avx2.h      |  4 ++--
190885
 sysdeps/x86_64/multiarch/ifunc-impl-list.c | 12 +++++++++---
190885
 2 files changed, 11 insertions(+), 5 deletions(-)
190885
190885
diff --git a/sysdeps/x86_64/multiarch/ifunc-avx2.h b/sysdeps/x86_64/multiarch/ifunc-avx2.h
190885
index e0f30e61..ef72b73f 100644
190885
--- a/sysdeps/x86_64/multiarch/ifunc-avx2.h
190885
+++ b/sysdeps/x86_64/multiarch/ifunc-avx2.h
190885
@@ -30,11 +30,11 @@ IFUNC_SELECTOR (void)
190885
   const struct cpu_features* cpu_features = __get_cpu_features ();
190885
 
190885
   if (CPU_FEATURE_USABLE_P (cpu_features, AVX2)
190885
+      && CPU_FEATURE_USABLE_P (cpu_features, BMI2)
190885
       && CPU_FEATURES_ARCH_P (cpu_features, AVX_Fast_Unaligned_Load))
190885
     {
190885
       if (CPU_FEATURE_USABLE_P (cpu_features, AVX512VL)
190885
-	  && CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)
190885
-	  && CPU_FEATURE_USABLE_P (cpu_features, BMI2))
190885
+	  && CPU_FEATURE_USABLE_P (cpu_features, AVX512BW))
190885
 	return OPTIMIZE (evex);
190885
 
190885
       if (CPU_FEATURE_USABLE_P (cpu_features, RTM))
190885
diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
190885
index 695cdba6..85b8863a 100644
190885
--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c
190885
+++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
190885
@@ -400,10 +400,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
190885
   /* Support sysdeps/x86_64/multiarch/strchr.c.  */
190885
   IFUNC_IMPL (i, name, strchr,
190885
 	      IFUNC_IMPL_ADD (array, i, strchr,
190885
-			      CPU_FEATURE_USABLE (AVX2),
190885
+			      (CPU_FEATURE_USABLE (AVX2)
190885
+			       && CPU_FEATURE_USABLE (BMI2)),
190885
 			      __strchr_avx2)
190885
 	      IFUNC_IMPL_ADD (array, i, strchr,
190885
 			      (CPU_FEATURE_USABLE (AVX2)
190885
+			       && CPU_FEATURE_USABLE (BMI2)
190885
 			       && CPU_FEATURE_USABLE (RTM)),
190885
 			      __strchr_avx2_rtm)
190885
 	      IFUNC_IMPL_ADD (array, i, strchr,
190885
@@ -417,10 +419,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
190885
   /* Support sysdeps/x86_64/multiarch/strchrnul.c.  */
190885
   IFUNC_IMPL (i, name, strchrnul,
190885
 	      IFUNC_IMPL_ADD (array, i, strchrnul,
190885
-			      CPU_FEATURE_USABLE (AVX2),
190885
+			      (CPU_FEATURE_USABLE (AVX2)
190885
+			       && CPU_FEATURE_USABLE (BMI2)),
190885
 			      __strchrnul_avx2)
190885
 	      IFUNC_IMPL_ADD (array, i, strchrnul,
190885
 			      (CPU_FEATURE_USABLE (AVX2)
190885
+			       && CPU_FEATURE_USABLE (BMI2)
190885
 			       && CPU_FEATURE_USABLE (RTM)),
190885
 			      __strchrnul_avx2_rtm)
190885
 	      IFUNC_IMPL_ADD (array, i, strchrnul,
190885
@@ -574,10 +578,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
190885
   /* Support sysdeps/x86_64/multiarch/wcschr.c.  */
190885
   IFUNC_IMPL (i, name, wcschr,
190885
 	      IFUNC_IMPL_ADD (array, i, wcschr,
190885
-			      CPU_FEATURE_USABLE (AVX2),
190885
+			      (CPU_FEATURE_USABLE (AVX2)
190885
+			       && CPU_FEATURE_USABLE (BMI2)),
190885
 			      __wcschr_avx2)
190885
 	      IFUNC_IMPL_ADD (array, i, wcschr,
190885
 			      (CPU_FEATURE_USABLE (AVX2)
190885
+			       && CPU_FEATURE_USABLE (BMI2)
190885
 			       && CPU_FEATURE_USABLE (RTM)),
190885
 			      __wcschr_avx2_rtm)
190885
 	      IFUNC_IMPL_ADD (array, i, wcschr,
190885
-- 
190885
GitLab
190885