]>
Commit | Line | Data |
---|---|---|
64b8b651 NG |
1 | /* Common definition for ifunc selections optimized wide-character |
2 | string copy functions. | |
3 | ||
4 | All versions must be listed in ifunc-impl-list.c. | |
6d7e8eda | 5 | Copyright (C) 2022-2023 Free Software Foundation, Inc. |
64b8b651 NG |
6 | This file is part of the GNU C Library. |
7 | ||
8 | The GNU C Library is free software; you can redistribute it and/or | |
9 | modify it under the terms of the GNU Lesser General Public | |
10 | License as published by the Free Software Foundation; either | |
11 | version 2.1 of the License, or (at your option) any later version. | |
12 | ||
13 | The GNU C Library is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | Lesser General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU Lesser General Public | |
19 | License along with the GNU C Library; if not, see | |
20 | <https://www.gnu.org/licenses/>. */ | |
21 | ||
22 | #include <init-arch.h> | |
23 | ||
24 | #ifndef GENERIC | |
25 | # define GENERIC generic | |
26 | #endif | |
27 | ||
28 | extern __typeof (REDIRECT_NAME) OPTIMIZE (evex) attribute_hidden; | |
29 | ||
52cf1100 NG |
30 | extern __typeof (REDIRECT_NAME) OPTIMIZE (avx2) attribute_hidden; |
31 | ||
64b8b651 NG |
32 | extern __typeof (REDIRECT_NAME) OPTIMIZE (GENERIC) attribute_hidden; |
33 | ||
34 | static inline void * | |
35 | IFUNC_SELECTOR (void) | |
36 | { | |
37 | const struct cpu_features *cpu_features = __get_cpu_features (); | |
38 | ||
39 | if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX2) | |
40 | && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, BMI2) | |
41 | && X86_ISA_CPU_FEATURES_ARCH_P (cpu_features, | |
42 | AVX_Fast_Unaligned_Load, )) | |
43 | { | |
44 | if (X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512VL) | |
45 | && X86_ISA_CPU_FEATURE_USABLE_P (cpu_features, AVX512BW)) | |
46 | return OPTIMIZE (evex); | |
52cf1100 NG |
47 | |
48 | if (X86_ISA_CPU_FEATURES_ARCH_P (cpu_features, | |
49 | Prefer_No_VZEROUPPER, !)) | |
50 | return OPTIMIZE (avx2); | |
51 | ||
64b8b651 NG |
52 | } |
53 | ||
54 | return OPTIMIZE (GENERIC); | |
55 | } |