https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120813
Bug ID: 120813 Summary: [15/16 Regression] RISC-V: Miscompile at -O[23] Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ewlu at rivosinc dot com Target Milestone: --- Testcase: short s (short t, short u) { return u == 0 ? 0 : t / u; } int x[6]; int y; unsigned ak = 1; unsigned short al = 65527; unsigned *am = &ak; int main() { for (int i = 0; i < 6; i++) { x[i] = i; } for (;;) { unsigned ar = 2080554998; char as = 4; if (s(34, al++) < ar) if (*am) break; } y = x[al & 5]; __builtin_printf("...checksum after hashing %lX\n", y ^ 5UL); } Commands: # -O3 > /scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc > -O3 ./runtime-bisect/red.c -o user-config.out -fsigned-char > -fno-strict-aliasing -fwrapv > QEMU_CPU=rv64,vlen=128,rvv_ta_all_1s=true,rvv_ma_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true > timeout --verbose -k 0.1 4 > /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out > 1 ...checksum after hashing 5 # -O2 > /scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc > -O2 ./runtime-bisect/red.c -o user-config.out -fsigned-char > -fno-strict-aliasing -fwrapv > QEMU_CPU=rv64,vlen=128,rvv_ta_all_1s=true,rvv_ma_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true > timeout --verbose -k 0.1 4 > /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out > 1 ...checksum after hashing 5 # -O1 > /scratch/ewlu/daily-upstream-build/build-gcv/bin/riscv64-unknown-linux-gnu-gcc > -O1 ./runtime-bisect/red.c -o user-config.out -fsigned-char > -fno-strict-aliasing -fwrapv > QEMU_CPU=rv64,vlen=128,rvv_ta_all_1s=true,rvv_ma_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true > timeout --verbose -k 0.1 4 > /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out > 1 ...checksum after hashing 4 Bisected to r15-9239-g4d7a634f6d4 as first bad commit. I'm not sure if this is the same error as pr120242 or if it's a different issue. Posting it just in case. If it is a dupe, this is another testcase Found via fuzzer.