]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/x86_64/multiarch/ifunc-memset.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / x86_64 / multiarch / ifunc-memset.h
CommitLineData
93e46f87
L
1/* Common definition for memset/memset_chk ifunc selections.
2 All versions must be listed in ifunc-impl-list.c.
6d7e8eda 3 Copyright (C) 2017-2023 Free Software Foundation, Inc.
93e46f87
L
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
5a82c748 18 <https://www.gnu.org/licenses/>. */
93e46f87
L
19
20#include <init-arch.h>
21
22extern __typeof (REDIRECT_NAME) OPTIMIZE (erms) attribute_hidden;
37ecc657
NG
23
24extern __typeof (REDIRECT_NAME) OPTIMIZE (avx512_unaligned)
93e46f87 25 attribute_hidden;
37ecc657
NG
26extern __typeof (REDIRECT_NAME) OPTIMIZE (avx512_unaligned_erms)
27 attribute_hidden;
28extern __typeof (REDIRECT_NAME) OPTIMIZE (avx512_no_vzeroupper)
29 attribute_hidden;
30
31extern __typeof (REDIRECT_NAME) OPTIMIZE (evex_unaligned)
32 attribute_hidden;
33extern __typeof (REDIRECT_NAME) OPTIMIZE (evex_unaligned_erms)
93e46f87 34 attribute_hidden;
37ecc657 35
93e46f87
L
36extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_unaligned) attribute_hidden;
37extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_unaligned_erms)
38 attribute_hidden;
7ebba913
L
39extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_unaligned_rtm)
40 attribute_hidden;
41extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2_unaligned_erms_rtm)
42 attribute_hidden;
37ecc657
NG
43
44extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2_unaligned)
93e46f87 45 attribute_hidden;
37ecc657 46extern __typeof (REDIRECT_NAME) OPTIMIZE (sse2_unaligned_erms)
93e46f87
L
47 attribute_hidden;
48
49static inline void *
50IFUNC_SELECTOR (void)
51{
37ecc657 52 const struct cpu_features *cpu_features = __get_cpu_features ();
93e46f87
L
53
54 if (CPU_FEATURES_ARCH_P (cpu_features, Prefer_ERMS))
55 return OPTIMIZE (erms);
56
37ecc657 57 if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512F)
93e46f87
L
58 && !CPU_FEATURES_ARCH_P (cpu_features, Prefer_No_AVX512))
59 {
37ecc657
NG
60 if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512VL)
61 && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)
62 && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2))
4e2d8f35
L
63 {
64 if (CPU_FEATURE_USABLE_P (cpu_features, ERMS))
65 return OPTIMIZE (avx512_unaligned_erms);
93e46f87 66
4e2d8f35
L
67 return OPTIMIZE (avx512_unaligned);
68 }
93e46f87 69
4e2d8f35 70 return OPTIMIZE (avx512_no_vzeroupper);
93e46f87
L
71 }
72
37ecc657 73 if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX2))
93e46f87 74 {
37ecc657
NG
75 if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512VL)
76 && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)
77 && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2))
1b968b6b
L
78 {
79 if (CPU_FEATURE_USABLE_P (cpu_features, ERMS))
80 return OPTIMIZE (evex_unaligned_erms);
81
82 return OPTIMIZE (evex_unaligned);
83 }
84
7ebba913
L
85 if (CPU_FEATURE_USABLE_P (cpu_features, RTM))
86 {
87 if (CPU_FEATURE_USABLE_P (cpu_features, ERMS))
88 return OPTIMIZE (avx2_unaligned_erms_rtm);
89
90 return OPTIMIZE (avx2_unaligned_rtm);
91 }
92
37ecc657
NG
93 if (X86_ISA_CPU_FEATURES_ARCH_P (cpu_features,
94 Prefer_No_VZEROUPPER, !))
1b968b6b
L
95 {
96 if (CPU_FEATURE_USABLE_P (cpu_features, ERMS))
97 return OPTIMIZE (avx2_unaligned_erms);
98
99 return OPTIMIZE (avx2_unaligned);
100 }
93e46f87
L
101 }
102
107e6a3c 103 if (CPU_FEATURE_USABLE_P (cpu_features, ERMS))
93e46f87
L
104 return OPTIMIZE (sse2_unaligned_erms);
105
106 return OPTIMIZE (sse2_unaligned);
107}