<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/99729>99729</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [RISC-V] Miscompile with -march=rv64gcv_zvl1024b -O2
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          patrick-rivos
      </td>
    </tr>
</table>

<pre>
    Testcase:
```c
_Bool arr_18[16][256];
int main() {
  for (int i_0 = 0; i_0 < 16; ++i_0)
 for (int i_1 = 0; i_1 < 16; ++i_1)
      for (int i_2 = 0; i_2 < 16; ++i_2)
        arr_18[i_0][i_1 * 16 + i_2] = (i_0 % 2);
  for (int i_0 = 0; i_0 < 8; ++i_0)
    __builtin_printf("%u\n", arr_18[i_0][0]);
}
```

Commands:
rv64gcv_zvl1024b:
```
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -O3 -march=rv64gcv_zvl1024b driver.c -o rv64gcv.out
> QEMU_CPU=rv64,vlen=1024,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/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 rv64gcv.out
0
0
0
1
1
1
1
1
```

rv64gcv:
```
> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -O3 driver.c -o rv64gcv.out
/scratch/tc-testing/compiler-fuzz-ci/csmith-discoveries/temp-13-467 main *2 !14 ?63 patrick@patrick 18:06:20
> QEMU_CPU=rv64,vlen=1024,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/tc-testing/tc-compiler-fuzz-trunk/build-gcv/bin/qemu-riscv64 rv64gcv.out
0
1
0
1
0
1
0
1
```

opt-bisect-limit points to `RISC-V DAG->DAG Pattern Instruction Selection on function`

Found via fuzzer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVk2P2zYT_jXjy4CGOJQl66CDba2DHILkfdP0KtA0ZbMriS5JKen--oKymv3ypi166KWGYc4M-cwXH5KW3ptTr3UJqy2sqoUcwtm68iKDM-qeOTNavzjY42_lT9oHJb0GsYGkgmQDWXL9qqteb61tUTpX8zWstjyDVQWrLa0mQWyvq0wfsJOmB1oDFQj5bEdsrEOgdVxg6gRBVJiA2M7KDnkWNaAt0NbUCVAxI58B-VMgvwHkj8Dp8wxNT9F0A00v0PhYcMxpqniKSxvkWYRFR7CqJscxTqyGVjg5En-5-PUbtSNiXR8G0wbT1xdn-tBMnSWg1QCrXT-JuxtZTsOTHCCvXuzrrE6_O9t1sj_677vvxiw9qbF-GFueUHp4TYtZFXcItPfKyaDOQPugWNA-mP50VZTtLqbVjjXDwwMLbujvgfaxpCM7qfG73LZjx1rTD9-iKRJor1rZn5B9FMg66dQZRPUyLTw6M2q3VMgszpNLO4TH5P539-FLvfv0ZQYD7cZW9yCqiAfauXGsg6xl29bcg6iCG_Rs7l6bxyei_hZqf9EKRDXyZQK0exi1oOZxycOos_QPHYPptB0CMjZqd7BeI7vHZMkx_ccdnNr1q-4G5oxXY5a-7kVya-B_Ptyky-z93yXFj7f-zfDPYysTTb4z4cyOxis7ame0jyDdXRgXLM3y6UaLZ54QiPMUQewzgfMtCmkyS8jXIDZJBmJDyX8UfIOC_O9qNyloL4EdjNcqsNZ0JuDFmj54DBYhS_7__vOO_YzV5h0DcVdt3uEnGYJ2Pb7vfXCDCsb2-Fm3-irZHpuhn-QXcfZ26I84Gomxdu2Wi2MpjoUo5EKXPCeeinzNaXEuFTVaZmstmkLKRmR5rrgohGykJs1lvjAlJZQmOSUJ5wmnZdZQwdd5Tk3BC5XlkCa6k6ZdRt4vrTstjPeDLosip2LRyoNu_fSSE_X6K06T8QFYVQtXTmflMJw8pElrfPCPXoIJ7fQX4NqW-Fx9iFyfNhW_mnD-wQ3LPtJicG15DuEyvQ-0B9qfTDgPh6WyHdA-BpoHdnH2F60C0H5KL56ka_pjSb8HAAD__8VCf1g">