https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116318

            Bug ID: 116318
           Summary: RISC-V: Miscompile at -O1 with -fwhole-program
           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, c, d;
short b[][8] = {};
int main() {
  for (; d < 7; d++) {
    a = b[d][c];
    __builtin_printf("%lX\n", a ^ 4095UL);
  }
}

Commands:
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
>  -fwhole-program -O1 preprocessed.c -o test.o
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 test.o
14FE
FC3
F97
75FC
FE7
FEB
FFF

> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
>  -fwhole-program -O0 preprocessed.c -o test.o
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 test.o
FFF
FFF
FFF
FFF
FFF
FFF
FFF

Found via fuzzer.

Reply via email to