GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
x86

X86: Avoid AVX-512 instruction generation on non-AVX512 CPUs.

Fixes a SIGILL error that occurred when AVX512 instructions were generated on CPUs lacking AVX512 support by adding a runtime CPU feature check.

The compiler was generating AVX512 instructions even when the target CPU lacked AVX512 support, leading to SIGILL errors. This commit extracts the test code into a separate function, do_test, and calls it only if __builtin_cpu_supports ("gfni") returns true, ensuring that AVX512 instructions are only executed on capable CPUs. This prevents the test from failing on CPUs without AVX512 support.

In Details

The fix addresses a scenario where enabling AVX512 via command line options led to the generation of AVX512 instructions before the runtime CPU feature check. The test shift-gf2p8affine-2.c was failing because the main function contained AVX512 instructions, causing a SIGILL signal on CPUs without AVX512. The do_test function now contains the AVX512 instructions, and main calls do_test only if __builtin_cpu_supports ("gfni") returns true.

For Context

Modern CPUs have many optional instruction set extensions that unlock performance. Compilers like GCC let you target these extensions at compile time, which can speed up code – but it'll crash on older machines without the right extensions. The compiler typically inserts a runtime check to ensure that the CPU supports the required features before executing the specialized code. This commit fixes an issue where AVX-512 instructions were being generated before the CPU feature check, leading to crashes on older CPUs. The fix ensures that the check happens first.

Filed Under: x86avx512sigilloptimization