https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128782
Bug ID: 128782
Summary: [17 Regression] ICE on RV32E with a register variable
in a6
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: mumumu0722 at gmail dot com
Target Milestone: ---
On RV32E, GCC trunk ICEs in riscv_output_move when a local register variable in
a6 is used as an inline asm operand. GCC 16.1 rejects the same code with a
normal error.
Similar bugs: 128778, 128780
int f(int v)
{
register int x __asm__("a6") = v;
__asm__ volatile("" : "+r"(x));
return x;
}
$ riscv32-unknown-linux-gnu-gcc -march=rv32e -mabi=ilp32e -S test.c
during RTL pass: final
test.c: In function 'f':
test.c:6:1: internal compiler error: in riscv_output_move, at
config/riscv/riscv.cc:5946
Output of -freport-bug (GCC trunk 4182b22649d4, riscv32-unknown-elf-gcc
-march=rv32e -mabi=ilp32e -freport-bug -S test.c):
// Target: riscv32-unknown-elf
// Configured with: /src/gcc/configure --target=riscv32-unknown-elf
--prefix=/opt/cross --enable-languages=c --without-headers --disable-bootstrap
--disable-multilib --disable-nls
// Thread model: single
// Supported LTO compression algorithms: zlib
// gcc version 17.0.0 20261115 (experimental) (GCC)
//
// during RTL pass: final
// test.c: In function 'f':
// test.c:6:1: internal compiler error: in riscv_output_move, at
config/riscv/riscv.cc:5946
// 6 | }
// | ^
// 0x341b38d internal_error(char const*, ...)
// /src/gcc/gcc/diagnostic-global-context.cc:787
// 0xedfb71 fancy_abort(char const*, int, char const*)
// /src/gcc/gcc/diagnostics/context.cc:1813
// 0xd9d2a3 riscv_output_move(rtx_def*, rtx_def*)
// /src/gcc/gcc/config/riscv/riscv.cc:5946
// 0x1228219 final_scan_insn_1
// /src/gcc/gcc/final.cc:2795
// 0x12285ab final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*)
// /src/gcc/gcc/final.cc:2908
// 0x12287d5 final_1
// /src/gcc/gcc/final.cc:1979
// 0x1229286 rest_of_handle_final
// /src/gcc/gcc/final.cc:4348
// 0x1229286 execute
// /src/gcc/gcc/final.cc:4426
// -quiet test.c -quiet -dumpbase test.c -dumpbase-ext .c -march=rv32e
-mabi=ilp32e -misa-spec=20191213 -march=rv32e -freport-bug -o - -frandom-seed=0
-fdump-noaddr
// Please submit a full bug report, with preprocessed source.
// Please include the complete backtrace with any bug report.
// See <https://gcc.gnu.org/bugs/> for instructions.
// /opt/cross/libexec/gcc/riscv32-unknown-elf/17.0.0/cc1 -quiet test.c -quiet
-dumpbase test.c -dumpbase-ext .c -march=rv32e -mabi=ilp32e -misa-spec=20191213
-march=rv32e -freport-bug -o - -frandom-seed=0 -fdump-noaddr
# 0 "test.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "test.c"
int f(int v)
{
register int x __asm__("a6") = v;
__asm__ volatile("" : "+r"(x));
return x;
}
Expected: an error, since a6 (x16) does not exist on RV32E (only x0-x15). GCC
16.1 rejects it (with a bit wrong reason):
test.c:3:18: error: register specified for 'x' isn't suitable for data type
Reproduced with GCC 17.0.0 20261115 (experimental), master 4182b22649d4.
https://godbolt.org/z/1TP84W7vb