<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/154911>154911</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Headers][X86] Convert bf16 to f32 conversions to generic constexpr implementations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
good first issue,
backend:X86,
clang:frontend,
clang:headers,
constexpr
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RKSimon
</td>
</tr>
</table>
<pre>
Now that we have the __bf16 type, the BF16 intrinsics can be converted to use standard conversions instead of bit twiddling that interferes with fp optimisations:
e.g.
```
static __inline__ float __DEFAULT_FN_ATTRS _mm_cvtsbh_ss(__bf16 __A) {
return __builtin_ia32_cvtsbf162ss_32(__A); // remove __builtin_ia32_cvtsbf162ss_32
}
```
-->
```
static __inline__ float __DEFAULT_FN_ATTRS_CONSTEXPR _mm_cvtsbh_ss(__bf16 __A) {
return (float)(__A);
}
```
and
```
static __inline__ __m512 __DEFAULT_FN_ATTRS512 _mm512_cvtpbh_ps(__m256bh __A) {
return _mm512_castsi512_ps((__m512i)_mm512_slli_epi32(
(__m512i)_mm512_cvtepi16_epi32((__m256i)__A), 16));
}
```
-->
```
static __inline__ __m512 __DEFAULT_FN_ATTRS512_CONSTEXPR _mm512_cvtpbh_ps(__m256bh __A) {
return (__m512)__builtin_convertvector(__A, __v16sf);
}
```
All the mask/maskz cvtpbh variants in avx512bf16intrin.h and avx512vlbf16intrin.h can be updated similarly
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVE1v4zYQ_TXUZRBDokzZOugg2zEKtEiLJAX2RlDkyGKXIgWSVjb99YU-kjSL7G63gAAJM_PI92Y0T4SgLxaxIuxA2CkR19g5X93_-qB7Z5PGqefqzj1B7ESEJ4ROjAixQ-C8abMC4vOAhB7n0OGcFaBt9NoGLQNIYaFBkM6O6CMqiA6uASFEYZXwas0E7WwAbUNEocC10OgI8UkrZbS9LDdrG9G36DHAk44dtAO4IepeBxEnOMlrkta4uWxIWpMiXZ-0DlFELYFzbY22yDm0xokInJ9uz_Wfvz3y8x2vHx_vH4D3PZdjDE3HQyB0vyrkvCa0BLI7kLQG8Biv3k7yr9pEbbkWOV1wbVbQEHhOZ_CEIvkBCD0TegaPvRvxB7i0JrvTVwpubkh--79V8ePvdw-Pt5_-uP85fYTu5yMnEf9S8yFDYdUP-XHes4x-QHCO9lNyIjc0HR8Wcj1lRdN9q_0rQoQY9PQ1gxYcy6gmtFxLgjGa46DnqUxHfFQkx4iDzoq3whcGc9Ginh4hK-aPb3biv83qe714P6-f7MqrtJn0y4-27t-IMjr_MswjcD5mRWi_o6Y2Zt7rXoTPhJ6n19-w0IFReC1snPYWxPiFZXT6mZbl33QgrFrDo3mXWD3hOigxOULQvTbCm-dEVbkq81IkWGU7xvaMsrRMukpiqrYUd0KwQkqpmEqFxKbcN8j2jdgmuqIpZeme0nS_3dNyg0rKIssla3cyL0sk2xR7oc3GmLHfOH9JdAhXrDK2LbMsMaJBE2b_o_TinIJW-xBhLiKUEnoklDZCfkarSF5_2hevUWmEvZC8br2zcUp_nehQKPThLe4mm_sy-CnCTomvJlI3zfUSyDY1OsTwRjPqaGZj_mU9hZ0IO0z3sxMcl6nC4sIO2py-89Po4IIWvZbweinofjDYo42LayZXb6ouxmH2z9mnLjp212YjXU_oeWKyvm4G7_5CGQk9z40JhJ7XBo4V_ScAAP__aePzBQ">