|
|
190885 |
From df380c9a1a74df30968bacb067ed77e583bd960d Mon Sep 17 00:00:00 2001
|
|
|
190885 |
From: "H.J. Lu" <hjl.tools@gmail.com>
|
|
|
190885 |
Date: Sun, 7 Mar 2021 09:44:18 -0800
|
|
|
190885 |
Subject: [PATCH] x86-64: Use ZMM16-ZMM31 in AVX512 memset family functions
|
|
|
190885 |
|
|
|
190885 |
Update ifunc-memset.h/ifunc-wmemset.h to select the function optimized
|
|
|
190885 |
with AVX512 instructions using ZMM16-ZMM31 registers to avoid RTM abort
|
|
|
190885 |
with usable AVX512VL and AVX512BW since VZEROUPPER isn't needed at
|
|
|
190885 |
function exit.
|
|
|
190885 |
|
|
|
190885 |
(cherry picked from commit 4e2d8f352774b56078c34648b14a2412c38384f4)
|
|
|
190885 |
---
|
|
|
190885 |
sysdeps/x86_64/multiarch/ifunc-impl-list.c | 14 +++++++++-----
|
|
|
190885 |
sysdeps/x86_64/multiarch/ifunc-memset.h | 13 ++++++++-----
|
|
|
190885 |
sysdeps/x86_64/multiarch/ifunc-wmemset.h | 12 ++++++------
|
|
|
190885 |
.../multiarch/memset-avx512-unaligned-erms.S | 16 ++++++++--------
|
|
|
190885 |
4 files changed, 31 insertions(+), 24 deletions(-)
|
|
|
190885 |
|
|
|
190885 |
diff --git a/sysdeps/x86_64/multiarch/ifunc-impl-list.c b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
|
|
|
190885 |
index c1efeec0..d969a156 100644
|
|
|
190885 |
--- a/sysdeps/x86_64/multiarch/ifunc-impl-list.c
|
|
|
190885 |
+++ b/sysdeps/x86_64/multiarch/ifunc-impl-list.c
|
|
|
190885 |
@@ -211,10 +211,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
190885 |
&& CPU_FEATURE_USABLE (AVX512BW)),
|
|
|
190885 |
__memset_chk_evex_unaligned_erms)
|
|
|
190885 |
IFUNC_IMPL_ADD (array, i, __memset_chk,
|
|
|
190885 |
- CPU_FEATURE_USABLE (AVX512F),
|
|
|
190885 |
+ (CPU_FEATURE_USABLE (AVX512VL)
|
|
|
190885 |
+ && CPU_FEATURE_USABLE (AVX512BW)),
|
|
|
190885 |
__memset_chk_avx512_unaligned_erms)
|
|
|
190885 |
IFUNC_IMPL_ADD (array, i, __memset_chk,
|
|
|
190885 |
- CPU_FEATURE_USABLE (AVX512F),
|
|
|
190885 |
+ (CPU_FEATURE_USABLE (AVX512VL)
|
|
|
190885 |
+ && CPU_FEATURE_USABLE (AVX512BW)),
|
|
|
190885 |
__memset_chk_avx512_unaligned)
|
|
|
190885 |
IFUNC_IMPL_ADD (array, i, __memset_chk,
|
|
|
190885 |
CPU_FEATURE_USABLE (AVX512F),
|
|
|
190885 |
@@ -252,10 +254,12 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
190885 |
&& CPU_FEATURE_USABLE (AVX512BW)),
|
|
|
190885 |
__memset_evex_unaligned_erms)
|
|
|
190885 |
IFUNC_IMPL_ADD (array, i, memset,
|
|
|
190885 |
- CPU_FEATURE_USABLE (AVX512F),
|
|
|
190885 |
+ (CPU_FEATURE_USABLE (AVX512VL)
|
|
|
190885 |
+ && CPU_FEATURE_USABLE (AVX512BW)),
|
|
|
190885 |
__memset_avx512_unaligned_erms)
|
|
|
190885 |
IFUNC_IMPL_ADD (array, i, memset,
|
|
|
190885 |
- CPU_FEATURE_USABLE (AVX512F),
|
|
|
190885 |
+ (CPU_FEATURE_USABLE (AVX512VL)
|
|
|
190885 |
+ && CPU_FEATURE_USABLE (AVX512BW)),
|
|
|
190885 |
__memset_avx512_unaligned)
|
|
|
190885 |
IFUNC_IMPL_ADD (array, i, memset,
|
|
|
190885 |
CPU_FEATURE_USABLE (AVX512F),
|
|
|
190885 |
@@ -719,7 +723,7 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
|
|
|
190885 |
CPU_FEATURE_USABLE (AVX512VL),
|
|
|
190885 |
__wmemset_evex_unaligned)
|
|
|
190885 |
IFUNC_IMPL_ADD (array, i, wmemset,
|
|
|
190885 |
- CPU_FEATURE_USABLE (AVX512F),
|
|
|
190885 |
+ CPU_FEATURE_USABLE (AVX512VL),
|
|
|
190885 |
__wmemset_avx512_unaligned))
|
|
|
190885 |
|
|
|
190885 |
#ifdef SHARED
|
|
|
190885 |
diff --git a/sysdeps/x86_64/multiarch/ifunc-memset.h b/sysdeps/x86_64/multiarch/ifunc-memset.h
|
|
|
190885 |
index 6f3375cc..19795938 100644
|
|
|
190885 |
--- a/sysdeps/x86_64/multiarch/ifunc-memset.h
|
|
|
190885 |
+++ b/sysdeps/x86_64/multiarch/ifunc-memset.h
|
|
|
190885 |
@@ -53,13 +53,16 @@ IFUNC_SELECTOR (void)
|
|
|
190885 |
if (CPU_FEATURE_USABLE_P (cpu_features, AVX512F)
|
|
|
190885 |
&& !CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_AVX512))
|
|
|
190885 |
{
|
|
|
190885 |
- if (CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_VZEROUPPER))
|
|
|
190885 |
- return OPTIMIZE (avx512_no_vzeroupper);
|
|
|
190885 |
+ if (CPU_FEATURE_USABLE_P (cpu_features, AVX512VL)
|
|
|
190885 |
+ && CPU_FEATURE_USABLE_P (cpu_features, AVX512BW))
|
|
|
190885 |
+ {
|
|
|
190885 |
+ if (CPU_FEATURE_USABLE_P (cpu_features, ERMS))
|
|
|
190885 |
+ return OPTIMIZE (avx512_unaligned_erms);
|
|
|
190885 |
|
|
|
190885 |
- if (CPU_FEATURE_USABLE_P (cpu_features, ERMS))
|
|
|
190885 |
- return OPTIMIZE (avx512_unaligned_erms);
|
|
|
190885 |
+ return OPTIMIZE (avx512_unaligned);
|
|
|
190885 |
+ }
|
|
|
190885 |
|
|
|
190885 |
- return OPTIMIZE (avx512_unaligned);
|
|
|
190885 |
+ return OPTIMIZE (avx512_no_vzeroupper);
|
|
|
190885 |
}
|
|
|
190885 |
|
|
|
190885 |
if (CPU_FEATURE_USABLE_P (cpu_features, AVX2))
|
|
|
190885 |
diff --git a/sysdeps/x86_64/multiarch/ifunc-wmemset.h b/sysdeps/x86_64/multiarch/ifunc-wmemset.h
|
|
|
190885 |
index bdc94c6c..98c5d406 100644
|
|
|
190885 |
--- a/sysdeps/x86_64/multiarch/ifunc-wmemset.h
|
|
|
190885 |
+++ b/sysdeps/x86_64/multiarch/ifunc-wmemset.h
|
|
|
190885 |
@@ -33,13 +33,13 @@ IFUNC_SELECTOR (void)
|
|
|
190885 |
if (CPU_FEATURE_USABLE_P (cpu_features, AVX2)
|
|
|
190885 |
&& CPU_FEATURES_ARCH_P (cpu_features, AVX_Fast_Unaligned_Load))
|
|
|
190885 |
{
|
|
|
190885 |
- if (CPU_FEATURE_USABLE_P (cpu_features, AVX512F)
|
|
|
190885 |
- && !CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_AVX512)
|
|
|
190885 |
- && !CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_VZEROUPPER))
|
|
|
190885 |
- return OPTIMIZE (avx512_unaligned);
|
|
|
190885 |
-
|
|
|
190885 |
if (CPU_FEATURE_USABLE_P (cpu_features, AVX512VL))
|
|
|
190885 |
- return OPTIMIZE (evex_unaligned);
|
|
|
190885 |
+ {
|
|
|
190885 |
+ if (!CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_AVX512))
|
|
|
190885 |
+ return OPTIMIZE (avx512_unaligned);
|
|
|
190885 |
+
|
|
|
190885 |
+ return OPTIMIZE (evex_unaligned);
|
|
|
190885 |
+ }
|
|
|
190885 |
|
|
|
190885 |
if (CPU_FEATURE_USABLE_P (cpu_features, RTM))
|
|
|
190885 |
return OPTIMIZE (avx2_unaligned_rtm);
|
|
|
190885 |
diff --git a/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S b/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S
|
|
|
190885 |
index 0783979c..22e7b187 100644
|
|
|
190885 |
--- a/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S
|
|
|
190885 |
+++ b/sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S
|
|
|
190885 |
@@ -1,22 +1,22 @@
|
|
|
190885 |
#if IS_IN (libc)
|
|
|
190885 |
# define VEC_SIZE 64
|
|
|
190885 |
-# define VEC(i) zmm##i
|
|
|
190885 |
+# define XMM0 xmm16
|
|
|
190885 |
+# define YMM0 ymm16
|
|
|
190885 |
+# define VEC0 zmm16
|
|
|
190885 |
+# define VEC(i) VEC##i
|
|
|
190885 |
# define VMOVU vmovdqu64
|
|
|
190885 |
# define VMOVA vmovdqa64
|
|
|
190885 |
+# define VZEROUPPER
|
|
|
190885 |
|
|
|
190885 |
# define MEMSET_VDUP_TO_VEC0_AND_SET_RETURN(d, r) \
|
|
|
190885 |
- vmovd d, %xmm0; \
|
|
|
190885 |
movq r, %rax; \
|
|
|
190885 |
- vpbroadcastb %xmm0, %xmm0; \
|
|
|
190885 |
- vpbroadcastq %xmm0, %zmm0
|
|
|
190885 |
+ vpbroadcastb d, %VEC0
|
|
|
190885 |
|
|
|
190885 |
# define WMEMSET_VDUP_TO_VEC0_AND_SET_RETURN(d, r) \
|
|
|
190885 |
- vmovd d, %xmm0; \
|
|
|
190885 |
movq r, %rax; \
|
|
|
190885 |
- vpbroadcastd %xmm0, %xmm0; \
|
|
|
190885 |
- vpbroadcastq %xmm0, %zmm0
|
|
|
190885 |
+ vpbroadcastd d, %VEC0
|
|
|
190885 |
|
|
|
190885 |
-# define SECTION(p) p##.avx512
|
|
|
190885 |
+# define SECTION(p) p##.evex512
|
|
|
190885 |
# define MEMSET_SYMBOL(p,s) p##_avx512_##s
|
|
|
190885 |
# define WMEMSET_SYMBOL(p,s) p##_avx512_##s
|
|
|
190885 |
|
|
|
190885 |
--
|
|
|
190885 |
GitLab
|
|
|
190885 |
|