]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Add sse42 implementation to strcmp's ifunc
authorNoah Goldstein <goldstein.w.n@gmail.com>
Tue, 14 Jun 2022 22:37:28 +0000 (15:37 -0700)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 15 Jun 2022 03:58:09 +0000 (20:58 -0700)
This has been missing since the the ifuncs where added.

The performance of SSE4.2 is preferable to to SSE2.

Measured on Tigerlake with N = 20 runs.
Geometric Mean of all benchmarks SSE4.2 / SSE2: 0.906

sysdeps/x86_64/multiarch/strcmp.c

index a248c2a6e6bd4ab1139e4c753702d2af992a1c2c..9c1677724cf7c32eef819ac54c200aed8d673e26 100644 (file)
@@ -28,6 +28,7 @@
 
 extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2) attribute_hidden;
 extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2_unaligned) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (sse42) attribute_hidden;
 extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden;
 extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_rtm) attribute_hidden;
 extern __typeof (REDIRECT_NAME) OPTIMIZE (evex) attribute_hidden;
@@ -52,6 +53,10 @@ IFUNC_SELECTOR (void)
        return OPTIMIZE (avx2);
     }
 
+  if (CPU_FEATURE_USABLE_P (cpu_features, SSE4_2)
+      && !CPU_FEATURES_ARCH_P (cpu_features, Slow_SSE4_2))
+    return OPTIMIZE (sse42);
+
   if (CPU_FEATURES_ARCH_P (cpu_features, Fast_Unaligned_Load))
     return OPTIMIZE (sse2_unaligned);