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

    <tr>
        <th>Summary</th>
        <td>
            RISCV vector zvl256b miscompile at -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
int printf(const char *, ...);
int c;
int d[10][10];
char e, f;
int main() {
  for (f = 0; f < 8; f += 1) {
    --c >> d[0][4] && (e = 0);
    d[0][4] = d[5][0];
  }
  printf("%X\n", d[0][4]);
}
```

Commands:
```bash
> /scratch/tc-testing/tc-feb-20-llvm/build/bin/clang -march=rv64gcv_zvl256b -O2 red.c -o red.out
> /scratch/tc-testing/tc-feb-20-llvm/build/bin/qemu-riscv64 red.out
AB2B8CB8
> /scratch/tc-testing/tc-feb-20-llvm/build/bin/clang -march=rv64gcv_zvl256b -O2 red.c -o red.out -fuse-ld=lld
> /scratch/tc-testing/tc-feb-20-llvm/build/bin/qemu-riscv64 red.out
555599E0
> /scratch/tc-testing/tc-feb-20-llvm/build/bin/clang red.c -o red.out
> /scratch/tc-testing/tc-feb-20-llvm/build/bin/qemu-riscv64 red.out
0
```

Bugpoint, ASM, red.c: [c-asm-bc.zip](https://github.com/llvm/llvm-project/files/14351798/c-asm-bc.zip)

`--opt-bisect-limit` points to `SLPVectorizerPass`

Discovered/tested using 7f3980a7b2c9f95ab3b106a94fe6e63158155b0b (not bisected)
Found using fuzzer
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVV-L67YT_TTjF6EgjyzHfvBDHG_gB7_SS7dc-lYkWXbU2lYqySnNpy9ysnt390KhcNtCyPxR5ujMGUmRIdhxMaYB0YLoMrnGs_PNRUZv9a_U26sLmXL9H82PJkQtgwF-ANYBO0DJ7h99j-0SycXbJQ6AlXZLiESfpSeAB8Aj2e12gDXw9suv9buoB9HmDET3al9WNxiTQIZ3FbO0C2AFWBPYP_KEDC7tWQ0EeEcY8JYk90iqh4ttWsg_VBFCqSbAn4A_bVQeTAoQHQEsAcuEah6obzpJtV8V8G7LiXvuXTeEwL57cV8FA0RA8ROI47K5x4-Yb7d8BXidwSPcvo9unuXSh68npWQ4P1L8iQCegvYy6jPgKWoaTYh2Ge_BYBRFRqfpOgOe1GqnPtkk-ElPchkJnaXXZ-Cdv5bFqK8_364TilIR-j0Sb_qdJtRtjlvjN9j1NzOv1Nugr2XxHvbQYlsd2-q_aY3QYQ2GTj3wbpr6f7RTIYSo6yf2zTr9V-fE_uLQtut4cXaJ6eQfnr9LZuMG_EBAtJrKMFOldzd72S5DdY7xsh1xPAGeRhvPq9ppl_g8aCVDL979YnQEPA12MgHwlBdc5Pu6Shq8RcX6LR8oGaXuEqmywehIJzvbCCUjG8tAoiNQsuf_f_psdHTe3oz_JEP40FVng3ZX402SJyloerIGu4xkP_C6YnKvUNdDLaTiKmelrIvBlKbkuahyIRRT6dFZXCR3GgnnQfPk1uUFbFhvN-OzvuF9zWuZmSbfs6oo93VeZOemyEvEXstcFqVQlWCVNMUwKNOzYi8RM9sgw4IhMkQUebEr86IURppBlb0cuIGCmVnaaZc03Tk_ZjaE1TQVFpxlk1RmCttfCOJififbYnrGRJf5ZpuDWscABZtsiOELSrRxMs0P_3s-fibXTUjyctXmJN18sZMhMqaLl61-av721Dcqaewb1T8DAAD__3O1AmI">