https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122652
Bug ID: 122652
Summary: RISCV: Crash at -O3 during RTL pass: vsetvl
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ybni at cse dot cuhk.edu.hk
Target Milestone: ---
This code crashed at `-O3`:
```c
int a;
#include "riscv_vector.h"
int b();
int c() {
if (b())
a = 0;
}
void d() {
for (; c() + d;) {
long e, h;
char *f;
__rvv_uint16mf4_t g;
__rvv_uint8mf8x3_t i = __riscv_vlseg3e8ff_v_u8mf8x3(f, &h, e);
__riscv_vsoxseg3ei16_v_u8mf8x3(0, g, i, 0);
}
}
```
Compile command:
```sh
riscv64-unknown-linux-gnu-gcc -O3 -march=rv64gcv -mabi=lp64d
```
Compiler Explorer: https://godbolt.org/z/fezo5s5dM
Backtrace:
```sh
during RTL pass: vsetvl
<source>: In function 'd':
<source>:16:1: internal compiler error: Segmentation fault
16 | }
| ^
0x7b41c6229e3f __libc_start_main
???:0
```
Compiler version:
```sh
$ riscv64-unknown-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=riscv64-unknown-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/data/yunboni/utils/compilers/riscv-gcc/libexec/gcc/riscv64-unknown-linux-gnu/15.1.0/lto-wrapper
Target: riscv64-unknown-linux-gnu
Configured with:
/data/yunboni/utils/compilers/repos/riscv-gnu-toolchain/gcc/configure
--target=riscv64-unknown-linux-gnu
--prefix=/data/yunboni/utils/compilers/riscv-gcc
--with-sysroot=/data/yunboni/utils/compilers/riscv-gcc/sysroot
--with-pkgversion=g1b306039a --with-system-zlib --enable-shared --enable-tls
--enable-languages=c,c++,fortran --disable-libmudflap --disable-libssp
--disable-libquadmath --disable-libsanitizer --disable-nls --disable-bootstrap
--src=.././gcc --disable-default-pie --disable-multilib --with-abi=lp64d
--with-arch=rv64gc --with-isa-spec=20191213 'CFLAGS_FOR_TARGET=-O2
-mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-O2 -mcmodel=medlow'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.1.0 (g1b306039a)
```