From c69b7fa19c1c5ecc2b6f2b97e99bf9a21cc2569e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 6 Nov 2026 21:09:28 +0530 Subject: [PATCH] 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. --- kitty/simd-string.c | 11 +++++------ setup.py | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/kitty/simd-string.c b/kitty/simd-string.c index bcc0c8b5e..0005146e2 100644 --- a/kitty/simd-string.c +++ b/kitty/simd-string.c @@ -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__ diff --git a/setup.py b/setup.py index 633124a65..08e7cc3a7 100755 --- a/setup.py +++ b/setup.py @@ -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')