<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/85374>85374</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV] Miscompile at -O3 with rvv
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:RISC-V,
miscompilation
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
Reduced test case: https://godbolt.org/z/rcKc4Woee
```
#include <stdio.h>
#include <stdint.h>
int32_t a[3];
int main() {
int f, b;
for (b = 0; b < 3; b++)
a[b] = ~(a[b] < 2);
for (f = 0; f < 2; f++)
printf("%d\n", a[1]);
return 0;
}
```
```
> gcc test.c && ./a.out
-2
-2
> clang --target=riscv64-linux-gnu -march=rv64gcv -O3 test.c
> qemu-riscv64 -L /usr/riscv64-linux-gnu -cpu rv64,v=true,vext_spec=v1.0 ./a.out
-2
254
```
LLVM version: 0a739eb75fe68b1cec4e4aaad8b5395bb5da9a89
QEMU version: v8.2.1
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VEuPpDYQ_jXFxQJBmeeBw3QzSFFmFGWjTI4rPwraCQ0d27Cze8hvj0z37sxmZyIhufBX9dXTJZwz40zUQnGAoovE6k-LbbVXz18-f4rkoj-3H0ivijTz5DxTwhHwO3by_uKA3wH2gP24aLlMPlnsCNh_Aeyt-lnlfyxEkHaQ3kGZ3r7rL3Izq2nVxIAfnddmSU7A799DZ_8KNrPn-NEzAcWBQ9EBP3wD2FmYGbAGbBhUt3vGAjIAHpn8pszYsFgGWEsGvGMp8AML4pHxXQQ87F_zVZ3tDiUU3W7wD2D96uLIMOj-wD68sA83tSC-wX6xZvbDHjsCFhqK47yLx91xFjL9zoMlv9p5577Vrerervabl_yejUrtXU0UAywBS5YA9iJZVn9VivH7MxipScwji2Mv7EgeeGeNU1uZx5OZ1-d4nFcWn4VVpwBtZT6qjcW_8JujF56_6bzGN1sWPzDAfnU2jM6PfOqyssAFeNyAd96uFER69h_dhRTwbsuS9L3oscj_py4PD0-PbCPrzDKHyU5FxRuSVTFQWctMkcopF0LoWha8KaQstGhEfevcr_ePv7-23uoEk-yKRbrluuGNiKjNqizNmzzNy-jUpjrlYhC1aoiyoRpEWVVZWcuqlJksCSPTYop5yrMibbI8LRMiJVATcaVFVWkBeUpnYaZkmrZzeHaRcW6lti54lUeTkDS5_U0jSqH-olkDv_vw02_H-Ok6U4B4Nk4t54uZhA_BI4YFYNvAGMt1dJCnk3Hevfjwxk_7qghMT2HwH79yEBN-b_Mn40_Mblu02qn9z5Yw_rTKRC1nwD6Q3o74Ypc_SXnAfs_CAfZ7Iv8GAAD__w20SXA">