https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104704
Bug ID: 104704 Summary: [12 Regression] ix86_gen_scratch_sse_rtx doesn't work explicit XMM7/XMM15/XMM31 usage Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com CC: crazylht at gmail dot com, ubizjak at gmail dot com Target Milestone: --- ix86_gen_scratch_sse_rtx returns XMM7/XMM15/XMM31 as a scratch register to prevent RTL optimizer from removing scratch vector register. But it introduces a conflict with explicit XMM7/XMM15/XMM31 usage: [hjl@gnu-tgl-2 scratch-2]$ cat x-2.c /* { dg-do compile { target { ! ia32 } } } */ /* { dg-options "-O2 -march=x86-64 -mavx2" } */ #include <immintrin.h> __m256d y, z; int i; __attribute__((noipa)) int do_test (void) { register int xmm15 __asm ("xmm15") = i; asm volatile ("" : "+v" (xmm15)); z = y; register int xmm2 __asm ("xmm2") = xmm15; asm volatile ("" : "+v" (xmm2)); return xmm2; } __attribute__((target("arch=x86-64"))) int main (void) { if (__builtin_cpu_supports ("avx2")) { i = 4; if (do_test () != 4) __builtin_abort (); } return 0; } [hjl@gnu-tgl-2 scratch-2]$ make x-2 /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -O2 -march=x86-64 -mavx2 -S x-2.c /export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-debug/build-x86_64-linux/gcc/ -O2 -march=x86-64 -o x-2 x-2.s [hjl@gnu-tgl-2 scratch-2]$ ./x-2 Aborted (core dumped) [hjl@gnu-tgl-2 scratch-2]$