Do not require AVX-512 VBMI2 for the AVX-512 SIMD code

VBMI2 was only used by the AVX-512 UTF-8 decoder, which has been
removed, so CPUs with AVX-512 F, BW and VL but not VBMI2, such as
Skylake-X, can now use the AVX-512 implementations of the remaining
functions.
This commit is contained in:
Kovid Goyal 2026-11-06 21:09:28 +05:30
parent fd22b77241
commit be7bc4d212
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 7 deletions

View file

@ -347,12 +347,11 @@ init_simd(void *x) {
Py_INCREF(Py_##val); \
if (0 != PyModule_AddObject(module, #x, Py_##val)) return false; \
}
#define do_check() \
{ \
has_sse4_2 = __builtin_cpu_supports("sse4.2") != 0; \
has_avx2 = __builtin_cpu_supports("avx2") != 0; \
has_avx512 = __builtin_cpu_supports("avx512f") && __builtin_cpu_supports("avx512bw") && __builtin_cpu_supports("avx512vl") && \
__builtin_cpu_supports("avx512vbmi2"); \
#define do_check() \
{ \
has_sse4_2 = __builtin_cpu_supports("sse4.2") != 0; \
has_avx2 = __builtin_cpu_supports("avx2") != 0; \
has_avx512 = __builtin_cpu_supports("avx512f") && __builtin_cpu_supports("avx512bw") && __builtin_cpu_supports("avx512vl"); \
}
#ifdef __APPLE__

View file

@ -979,7 +979,7 @@ def get_source_specific_cflags(env: Env, src: str) -> List[str]:
elif src == 'kitty/simd-string-512.c':
# uses native AVX-512 intrinsics, only compiled on x86-64, selected at runtime only when the CPU supports these features
if env.binary_arch.isa is ISA.AMD64:
ans.extend(('-mavx512f', '-mavx512bw', '-mavx512vl', '-mavx512vbmi2'))
ans.extend(('-mavx512f', '-mavx512bw', '-mavx512vl'))
# We have manual vzeroupper so prevent compiler from emitting it causing duplicates
if env.compiler_type is CompilerType.clang:
ans.append('-mllvm')