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

            Bug ID: 116149
           Summary: RISC-V: Miscompile at -O3 with zvl256b
                    -mrvv-vector-bits=zvl
           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:
long a;
short b[60000];
short c[20];
int main() {
  for (short d = 0; d < 20; d += 3) {
    c[d] = 0;
    for (int e = 0; e < 20; e += 2)
      for (int f = 1; f < 20; f += 2)
        a += (unsigned)b[f + e];
  }
  __builtin_printf("%lu\n", a);
}

Commands:
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
>  -march=rv64gcv_zvl256b -O3 -mrvv-vector-bits=zvl red.c -o red.out
> QEMU_CPU=rv64,vlen=256,rvv_ta_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true
>  timeout --verbose -k 0.1 4 
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 red.out
18446744073709551613

> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/riscv64-unknown-linux-gnu-gcc
>  -march=rv64gcv_zvl256b -O2 -mrvv-vector-bits=zvl red.c -o red.out
> QEMU_CPU=rv64,vlen=256,rvv_ta_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true
>  timeout --verbose -k 0.1 4 
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 red.out
0

Still present when rvv_ta_all_1s=true is omitted.

Found via fuzzer

Reply via email to