Issue |
83947
|
Summary |
[RISC-V] Miscompile at -O2
|
Labels |
new issue
|
Assignees |
|
Reporter |
patrick-rivos
|
Testcase:
```c
int printf(const char *, ...);
int a, c = 1;
int b[2];
int main() {
d:
for (; a < 8; a += 1) {
int *e = &c;
if (&b[1] == e)
*e = 0;
}
f:
if (0) {
goto f;
goto d;
}
printf("%d\n", c);
}
```
The condition `if (&b[1] == e)` should never be true.
Commands:
```bash
> /scratch/tc-testing/tc-mar-4-llvm/build/bin/clang -march=rv64gcv -O2 red.c -o red.out -fno-strict-aliasing
> /scratch/tc-testing/tc-mar-4-llvm/build/bin/qemu-riscv64 red.out
0
> /scratch/tc-testing/tc-mar-4-llvm/build/bin/clang red.c -o red.out -fno-strict-aliasing
> /scratch/tc-testing/tc-mar-4-llvm/build/bin/qemu-riscv64 red.out
1
```
Godbolt: https://godbolt.org/z/eEfqjf5rr
`-opt-bisect-limit` points at `InstCombinePass`
Discovered/tested using version 57592e9ae78e16ffe4f2a2cd3190c422bcdba5a0 (not bisected)
Found using fuzzer
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs