<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/134524>134524</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Use bfcvt instruction on Arm to convert to __bf16
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DesWurstes
</td>
</tr>
</table>
<pre>
Documentation for `bfcvt`: https://developer.arm.com/documentation/ddi0602/2025-03/SVE-Instructions/BFCVT--Single-precision-down-convert-to-BFloat16-format--predicated--
This code when compiled with `-march=armv9-a+fp16 -O3` could use the instruction for better performance:
```c
void convert2(float * __restrict a, __bf16 * __restrict x) {
x[0] = (__bf16)a[0];
x[1] = (__bf16)a[1];
x[2] = (__bf16)a[2];
x[3] = (__bf16)a[3];
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0k8tupDwQhZ-m2JTcMjbXBQs6_SP9q1kkk1m2jCkajwC3bENn3n4E6ZkkE0VC4lKfi-PjU8p7c5mJKkiPkJ4itYTBuupE_sfifCAftbb7VZ2sXiaagwrGzthbh5DxttdrgIyDrHEI4epB1iAaEE1HK432Su6g3HTQdtq-vW-xvXeGZ1yAaAQXKeMSRPP4_B_7f_bBLXqjPIjm2Dw8PzH2aObLSOzqSBtv7Mw6e5uZtvNKLrBg2bEZrQpxxnrrJhXYhnZGq0AdY8Br4PXTYDxq2xHeBppR2-lqRurwZsKw7YdNyukB5Em5aS2ZAnHsr3GG7JuEjKO2y9jh4gnDQGjeZO5-tBQCObyS2wXMmjY39v9uFu2XBl6v1nR41y1AFP0mG0HUeD478sEZHVCBeMDzue3j7N_SC4gSIT8CrxERXyA9ckhPCPKEIIrXRSBKdS-AfI_GX6HxJ1R8hYpPqPwKlX9RyE_vnXg1Juoq2ZWyVBFVcZ7IUhQiLqKh0nGZt0qLoshz6stMd2kfS9HnMmnTrMsiU22h4QnPeCF5XBzaVOZZn6RpkWe57ktIOE3KjIdxXKeDdZfIeL9QFcskFUk0qpZGv4deiJluuFdBbHuLXLUtYu1y8ZDw0fjg39oEE0aqvnvCPf4fcmBnrN2Ewf454O3x1ZBocWP1cUguJgxLe5-Orf_9xq7O_iQdQDS7qm0K7rLXSvwOAAD__1pBHDk">