Issue 89833
Summary [RISC-V] rv64gcv miscompile at `-O2 -flto` with pass `gather/scatter lowering`
Labels new issue
Assignees
Reporter patrick-rivos
    Testcase:
```c
short a;
long long b;
int c = 4;
signed char d[10], e[10];
int main() {
  for (long h = 0; h < 10; ++h)
    d[h] = 1;
  for (int h = 0; h < 10; h += c || a)
    e[h] = 256 / d[h];
  __builtin_printf("%d\n", e[1]);
}
```

Commands:
```bash
> /scratch/tc-testing/tc-apr-23/build-rv64gcv/build-llvm-linux/bin/clang -fwrapv -march=rv64gcv -flto -O2 red.c -o red.out
> /scratch/tc-testing/tc-apr-23/build-rv64gcv/bin/qemu-riscv64 red.out
1
> /scratch/tc-testing/tc-apr-23/build-rv64gcv/build-llvm-linux/bin/clang -fwrapv red.c -o red.out
> /scratch/tc-testing/tc-apr-23/build-rv64gcv/bin/qemu-riscv64 red.out
0
```

Discovered/tested using cebc9609d8cdc6f488693cd8e4a616b935b38d2c (not bisected)

Found via fuzzer.

flto opt-bisect-limit points to `pass (70) RISC-V gather/scatter lowering on function (main)`

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to