<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/144651>144651</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV] combineOp_VLToVWOp_VL can miscompile or crash with Zvfbfwma
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
topperc
</td>
</tr>
</table>
<pre>
This test case that mixes bf16 and f16 miscompiles to a vfwmacc.vv instruction when both Zvfh and Zvfbfwma are enabled.
```
define <4 x float> @fixed(<4 x float> %rd, <4 x half> %a, <4 x bfloat> %b) local_unnamed_addr #0 {
%a_ext = fpext <4 x half> %a to <4 x float>
%b_ext = fpext <4 x bfloat> %b to <4 x float>
%fma = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %a_ext, <4 x float> %b_ext, <4 x float> %rd)
ret <4 x float> %fma
}
```
This test case crashes with Zvfbfwma
```
define <4 x float> @fixed(<4 x float> %rd, <2 x bfloat> %a, <4 x bfloat> %b) local_unnamed_addr #0 {
%b_ext = fpext <4 x bfloat> %b to <4 x float>
%1 = extractelement <2 x bfloat> %a, i64 1
%a_extract = fpext bfloat %1 to float
%a_insert = insertelement <4 x float> poison, float %a_extract, i64 0
%a_shuffle = shufflevector <4 x float> %a_insert, <4 x float> poison, <4 x i32> zeroinitializer
%fma = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %a_shuffle, <4 x float> %b_ext, <4 x float> %rd)
ret <4 x float> %fma
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VV2L4zYU_TXyy2WDLH8kfvBDdqaBQqHQLlPYl-FavhqryJKRZE-6v77YcWaSbLov0xYMFpLOPUfnHtkYgn6xRDUrPrPiMcExds7X0Q0DeZk0rv2r_tLpAJFCBImBIHYYoddHCtCotAS0LczvXgfp-kEbChAdIEzqtUcpN9ME2oboRxm1s_DakYXGxQ6-Tqpb4F8n1cybAT0BWWwMtRvG9_NT8vXh-5aUtgQse8jhCMo4jCz7CVjOlT5Sy8TuuyVR-JaJhzOmQ6PWebyYbi4BDRMVGCfRPI_WYk_tM7atByYyDmz7mfE9LAWe6RiBZY-ghtPoO4rZhxtJZ3RzH32t5Ad41eOCjqgNSDTmni3GTP1G9biZcpWJ-_4sx7jw4krAD9ZmX6tFjad4b4Pqce7f9vGmi4zvbxIlPYaOArzqUyiWLPzb7Re37n44AB9tYbpg6Rg9ykiGerLxn5XqMof0Knsz7IL-BDkVjm5le9uvbSB_2n4aXhBeeTY4HZydGd_qvbGddfD3uqEblTK0FF7HE8no_L1InGXci9Q777qiMzHPfyPvtNVRo9HfyP8H-V9l_293IGnrrK2yChOq023BRZaLcpt0dcExr_IGJW2x3TUc05ZkxbHKZSupyBNdCy4KXqY7vktTvt3sOJa7vKi2TanygojlnHrUZrOc3PmXRIcwUp3meVmkicGGTFi-9UJYeoVllQkxf_p9PYM-NeNLmK3TIYb3MlFHs_wkfvv594cnVjyCdH2jLf06PD_98sU9_bEMQKK9-BGA86fLfX21k9GbuotxCCzbM3Fg4vCiYzc2G-l6Jg4z6_r6NHj3J83JOyxaAxOH9TBTLf4OAAD__yGEAwA">