https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81426
Sergei Trofimovich <slyfox at inbox dot ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |slyfox at inbox dot ru --- Comment #7 from Sergei Trofimovich <slyfox at inbox dot ru> --- Not sure if it's the same bug or not, but I get the same error building GHC for SH4. Reproducible on gcc-master and on gcc-9.2.0. Here is the minimal reproducer extracted by creduce: $ cat bug.c /* works: $ sh4-unknown-linux-gnu-gcc -o bug.o -c bug.c fails: $ sh4-unknown-linux-gnu-gcc -O -o bug.o -c bug.c error: error: unable to find a register to spill in class 'R0_REGS' */ inline int a(char *b, char c) { __sync_val_compare_and_swap(b, c, 0); } int d(void) { while (1) { char e; a(&e, e); } } $ LANG=C sh4-unknown-linux-gnu-gcc -o bug.o -c bug.c <ok> $ LANG=C sh4-unknown-linux-gnu-gcc -O -o bug.o -c bug.c bug.c: In function 'd': bug.c:15:1: error: unable to find a register to spill in class 'R0_REGS' 15 | } | ^ bug.c:15:1: error: this is the insn: (insn 18 13 41 4 (parallel [ (set (subreg:SI (reg:QI 6 r6 [174]) 0) (unspec_volatile:SI [ (mem/v:QI (reg/f:SI 2 r2 [176]) [-1 S1 A8]) (reg:QI 173 [ e ]) (reg:QI 3 r3 [177]) ] UNSPECV_CMPXCHG_1)) (set (mem/v:QI (reg/f:SI 2 r2 [176]) [-1 S1 A8]) (unspec_volatile:QI [ (const_int 0 [0]) ] UNSPECV_CMPXCHG_2)) (set (reg:SI 147 t) (unspec_volatile:SI [ (const_int 0 [0]) ] UNSPECV_CMPXCHG_3)) (clobber (scratch:SI)) (clobber (reg:SI 0 r0)) (clobber (reg:SI 1 r1)) ]) "bug.c":9:33 401 {atomic_compare_and_swapqi_soft_gusa} (expr_list:REG_DEAD (reg:QI 173 [ e ]) (expr_list:REG_UNUSED (reg:QI 6 r6 [174]) (expr_list:REG_UNUSED (reg:SI 147 t) (expr_list:REG_UNUSED (reg:SI 1 r1) (expr_list:REG_UNUSED (reg:SI 0 r0) (nil))))))) bug.c:15: confused by earlier errors, bailing out $ ./xgcc -B. -v Reading specs from ./specs COLLECT_GCC=./xgcc COLLECT_LTO_WRAPPER=./lto-wrapper Target: sh4-unknown-linux-gnu Configured with: ../gcc/configure --target=sh4-unknown-linux-gnu --prefix=/home/slyfox/dev/git/gcc-sh4/../gcc-sh4-installed --with-sysroot=/usr/sh4-unknown-linux-gnu --disable-bootstrap --enable-languages=c --disable-nls CFLAGS=-O0 CXXFLAGS=-O0 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 10.0.0 20191103 (experimental) (GCC)