Issue 80910
Summary RISCV64 vector miscompile at -O2
Labels new issue
Assignees
Reporter patrick-rivos
    Testcase:
```c
int printf(const char *, ...);
int b, e, z, v, h;
short i, j;
int *k = &b;
static int l;
static int *n = &l;
static int o;

static int r() {
  long x = 0;
  signed char y = 0;
  short w = 0;
  *k = 1;
  h = 0;
 n;
  while (h < 2) {
    e = i = 0;
    while (i < 3) {
      j = o << l;
      w = b * 3;
      e ^= j >= 0;
      long q = e;
 x = w & -q ?: w;
      y = x;
      z |= y;
      while (o < 2)
        o += 1;
      i += 1;
    }
    h++;
  }
 return z;
}

int main() {
  v = r();
  printf("%d\n", v);
}
```
Commands:
```bash
> /scratch/tc-testing/llvm-feb-5/build/bin/clang -O2 -march=rv64gcv red.c -o user-config.out -Wno-unused-value
> QEMU_CPU=rv64,Zve32f=true,Zve64f=true /scratch/tc-testing/llvm-feb-5/build/bin/qemu-riscv64 user-config.out
0
> /scratch/tc-testing/llvm-feb-5/build/bin/clang -O1 -march=rv64gcv red.c -o user-config.out -Wno-unused-value
> QEMU_CPU=rv64,Zve32f=true,Zve64f=true /scratch/tc-testing/llvm-feb-5/build/bin/qemu-riscv64 user-config.out
3
```

.c, .bc, .asm: 
[c-bc-asm.zip](https://github.com/llvm/llvm-project/files/14186745/c-bc-asm.zip)

`--opt-bisect-limit` points to `InstCombinePass`

Discovered/tested using a7bc9cb6ffa91ff0ebabc45c0c7263c7c2c3a4de (not bisected)
Found using fuzzer.

#80792 also fails with `-march=rv64gcv -O2` so these might be related?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to