https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123118
Bug ID: 123118
Summary: ICE during RTL pass in expand_insn at optabs.cc:8293
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: rvismith1115 at gmail dot com
Target Milestone: ---
The test case is reduced by C-Reduce.
Code link: https://godbolt.org/z/Tbr6h99no
$ riscv64-unknown-elf-g++ -O3 -march=rv64gcv_zvfh func.cpp
during RTL pass: expand
func.cpp: In function 'void g()':
func.cpp:6:6: internal compiler error: in expand_insn, at optabs.cc:8293
6 | void g() {
| ^
0x3362f4b internal_error(char const*, ...)
/home/riscv-files/gcc-16-20251123/gcc/diagnostic-global-context.cc:787
0xe647d5 fancy_abort(char const*, int, char const*)
/home/riscv-files/gcc-16-20251123/gcc/diagnostics/context.cc:1805
0xcd2af8 expand_insn(insn_code, unsigned int, expand_operand*)
/home/riscv-files/gcc-16-20251123/gcc/optabs.cc:8293
0xcd3463 expand_insn(insn_code, unsigned int, expand_operand*)
/home/riscv-files/gcc-16-20251123/gcc/optabs.cc:8264
0x157adf9 expand_scatter_store_optab_fn
/home/riscv-files/gcc-16-20251123/gcc/internal-fn.cc:3676
0x12a9faf expand_call_stmt
/home/riscv-files/gcc-16-20251123/gcc/cfgexpand.cc:3109
0x12a9faf expand_gimple_stmt_1
/home/riscv-files/gcc-16-20251123/gcc/cfgexpand.cc:4235
0x12a9faf expand_gimple_stmt
/home/riscv-files/gcc-16-20251123/gcc/cfgexpand.cc:4382
0x12b085f expand_gimple_basic_block
/home/riscv-files/gcc-16-20251123/gcc/cfgexpand.cc:6501
0x12b28e7 execute
/home/riscv-files/gcc-16-20251123/gcc/cfgexpand.cc:7248
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
$ riscv64-unknown-elf-g++ --version
riscv64-unknown-elf-g++ () 16.0.0 20251123 (experimental)
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Reproducer:
long long a;
short c, d;
extern int e[][1][1][1];
extern bool f[][1][4][2];
#include <vector>
void g() {
for (bool b;;)
for (signed char h(c); h < 4; h += -4487 - 119) {
e[b][b][b][b] = std::max(std::min((long long)3, a), (long long)d);
f[0][0][h][1] = h;
}
}