]> git.ipfire.org Git - thirdparty/gcc.git/commit
x86: Fix shift-gf2p8affine-2.c failure on non-AVX512 CPU
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 2 May 2026 20:39:19 +0000 (04:39 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 5 May 2026 00:51:20 +0000 (08:51 +0800)
commit4e45547e66cc7bc144ccfeffabe4856175a8a699
tree17960f9d6bfe4f9661c0f00e1aefa73954cd7f9f
parent9127d1c42f7116bd82372f93d6cc22af89be5316
x86: Fix shift-gf2p8affine-2.c failure on non-AVX512 CPU

Enabling AVX512 via command line may cause the compiler to generate
AVX512 instructions even before the runtime CPU feature check, causing
the test to SIGILL if the CPU lacks AVX512.  Extract tests to do_test
and change main to call only if __builtin_cpu_supports ("gfni") returns
true to avoid any AVX512 instructions in main:

main:
        movq    __cpu_features2@GOTPCREL(%rip), %rax
        testb   $1, (%rax)
        jne     .L1577
        xorl    %eax, %eax
        ret
.L1577:
        pushq   %rax
        call    do_test
        xorl    %eax, %eax
        popq    %rdx
        ret

* gcc.target/i386/shift-gf2p8affine-2.c (do_test): New function.
Extracted from main.
(main): Drop __builtin_cpu_init.  Call do_test only if
__builtin_cpu_supports ("gfni") returns true.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
gcc/testsuite/gcc.target/i386/shift-gf2p8affine-2.c