Issue 126974
Summary [RISC-V] Miscompile using rv64gcv
Labels new issue
Assignees
Reporter ewlu
    Testcase:
```c
int a[][21][21];
void b(int c, int d, int e, short f, _Bool g, char h, char i, int j, int k,
       int l, unsigned char m, int n, char o, int p, long long q[],
       unsigned short r[][10], unsigned s[][10],
       unsigned long long t[][10][10][10], unsigned long long u[][10][10][10],
       int w[][10][10][10][10], _Bool x) {
  for (signed z = 0; z < (char)m + 3; z = 4)
    for (short aa = ({
 __typeof__(0) ab = 173;
                      __typeof__(0) ac = ({
                        __typeof__(0) ab = m;
 ab;
                      });
                      ab > ac ? ab : ac;
 }) -
                    171;
         aa < 9; aa = k)
 a[z][aa][aa] = ~0;
}
typedef int ad;
int printf(const char *, ...);
long long ae;
void af(long long *ae, int v) { *ae ^= v; }
int c;
int d;
int e;
short f;
_Bool g;
char h;
char i;
int j;
int k = 2805750831;
int l;
char m;
int n;
char o;
int p;
long long q[0];
unsigned short r[0][10];
unsigned s[0][10];
unsigned long long t[0][10][10][10];
unsigned long long u[0][10][10][10];
int w[0][10][10][10][10];
_Bool x;
int a[21][21][21];
void ag() {
  for (ad y = 0; y < 10; ++y)
    for (ad ah = 0; ah < 10; ++ah)
      for (ad ai = 0; ai < 10; ++ai)
        af(&ae, a[y][ah][ai]);
}
int main() {
  b(c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, w, x);
  ag();
 printf("%llu\n", ae);
}
```

Commands:
```
# riscv 
$ QEMU_CPU=rv64,vlen=128,rvv_ta_all_1s=true,rvv_ma_all_1s=true,v=true,vext_spec=v1.0,zve32f=true,zve64f=true timeout --verbose -k 0.1 4 /scratch/ewlu/daily-upstream-build/build-gcv/bin/qemu-riscv64 user-config.out 1
0

# x86
$ ./native.out 1
18446744073709551615
```

Godbolt: https://godbolt.org/z/85rz18rxY

Bisected to cfee344dda7394631f2177a15e56cfeee1d61fc4 as the first bad commit

I tried reducing the testcase down farther but was unsuccessful

Found via fuzzer. First detected 01/24/2025
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to