https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116715
Bug ID: 116715
Summary: RISC-V: Miscompile at -O2 with -march=rv64id_zbs
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: patrick at rivosinc dot com
Target Milestone: ---
Testcase:
int a, b;
int d;
long f = 695372830942;
void c(char g) { a = g; }
int main() {
d = 0;
for (; d < 1; d = 1)
--f;
d |= b = f;
long h = d;
c(h >> 40);
__builtin_printf("%lX\n", a ^ 5UL);
}
Commands:
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64idzbs -O1 preprocessed.c -o test.out
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 test.out
FA
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
> -march=rv64idzbs -O2 preprocessed.c -o test.out
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 test.out
5
Found via fuzzer.