Issue 84200
Summary [RISCV] Miscompile at -O3
Labels backend:RISC-V, miscompilation
Assignees dtcxzyw
Reporter dtcxzyw
    Reduced test case: https://godbolt.org/z/1sxbE8eco
```
#include <stdint.h>
#include <stdio.h>
int32_t a, f;
uint16_t e = 10;
static uint8_t f1(uint8_t c, uint8_t d) { return d == 0 ? 0 : c % d; }
static uint32_t f2(uint32_t c, uint32_t d) { return d == 0 ? c : 0; }
static int32_t *h(int32_t l) {
  int32_t *n = &a;
  return n;
}
static uint64_t g(int16_t k) {
  uint16_t m[] = {0, 3};
 int32_t *j = h(0);
  *j = f1(f2(1 && m[1], 0), e) == 0;
  return m[f];
}
int main() {
  g(f);
  printf("%d\n", a);
}
```

```
> clang -O0 test.c && ./a.out
0
> clang -O3 test.c --target=riscv64-linux-gnu
> qemu-riscv64 -L /usr/riscv64-linux-gnu/ ./a.out
-10
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to