<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62246>62246</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[fastmath/FP] #pragma contract off has no effect
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wolfy1961
</td>
</tr>
</table>
<pre>
Given the following source
```
typedef float __m128 __attribute__((__vector_size__(16), __aligned__(16)));
typedef float __v4sf __attribute__((__vector_size__(16)));
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__, __target__("sse"), __min_vector_width__(128)))
_mm_mul_ps(__m128 __a, __m128 __b)
{
return (__m128)((__v4sf)__a * (__v4sf)__b);
}
static __inline__ __m128 __attribute__((__always_inline__, __nodebug__, __target__("sse"), __min_vector_width__(128)))
_mm_add_ps(__m128 __a, __m128 __b)
{
return (__m128)((__v4sf)__a + (__v4sf)__b);
}
__m128 fp_using_intrinsics_contract_off(__m128 a, __m128 b, __m128 c, __m128 d)
{
#pragma clang fp contract (off)
return _mm_add_ps(_mm_mul_ps(a, b), _mm_mul_ps(c, d));
}
```
and compiled with 'clang -march=broadwell -O2 -ffast-math', clang generates
```
vmulps %xmm0, %xmm1, %xmm0
vfmadd231ps %xmm2, %xmm3, %xmm0 # xmm0 = (xmm3 * xmm2) + xmm0
```
despite the pragma. Adding -ffp-contract=off to the command line suppresses the contraction:
```
vmulps %xmm0, %xmm1, %xmm0
vmulps %xmm2, %xmm3, %xmm1
vaddps %xmm0, %xmm1, %xmm0
```
Issue [#53941](https://github.com/llvm/llvm-project/issues/53941) likely has the same root cause.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUlV_PuyYUx18N3pA2itrWCy-e35ouu9reAUE4KBuCAWzXvfoF1P558mTZb9ku1hgLev58zlcOMO9VbwBaVH9D9Tljcxisa29Wy3vRHIqss-Le_qiuYHAYAEurtb0p02NvZ8cB5WeUf6BDvl5pGu4TCJBYassCpnQsyAlTykJwqpsDUIrICZETpVfgwTrq1R_Lw-KASIPID9FaRzDx-jhd5bevk1wrL78ryVu05e4DC4pjSpXRygClfwnP9I3d_cN2wTZWQDf32zQw10NYfYj3gAh5lDgqs8HdlAjDQhctN7xERceRjrOmk09pN6A1xjLrHtbouJaEHYTZGfxwSjFXSSovEWkoZRiRD_z-rHsT5nj-fyjEhPjPFPr2HQqtCeVEZ69MT5UJThmvuKfcmuAYD9RK-QR9xexexvxlLL6AxxgjUk6O9SPDXDPTYznhLUckTmmap_la7rtar4sroXSb-q9vEoz43DSPyt_7nxmBuR0npUHgmwoDRuS4EO5G5viAynPnLBM30BrvfiZ4JyXzYTeyMCByjLkW8x4MOBbA4y8T4es468lHIerfxzGPjsuweA7zpwDxd5UjE4KURfTDmyt52pcvrqtFidMElecoa7RJbbP4NWmBPBN9YhTgJxUg7Z7Lx9rjDyHiFrqTctptHwyVZyslDjZZcjuOUcbYONjP0-TAe_Dru8VDWYPKj39PmDeXrwUptvBMiL8Z_hPZcv_J-xlwPHNIWZdNVaD6jMhpCGHysSZyQeTSqzDM3Z7bEZGL1tftbzc5-yvwgMhFxTgekcsShDRYq99A3_HAFq08GwE7awPmbPawX9Jnoi1FUzYsg7Y4nIqmyuu8yoZWdpzXR3k6lN2JV9AxKPKuasqKA5xKOGWqJTkp86poSFEVVbXPOxDHvCFSkLrmR0BVDiNTeh9J99b1WWJsD4RUh0yzDrRPhy0hBm44vYw7Xn3OXJuq6-beoyrXygf_jBJU0OmUjo2y9Mnl8guqz6-bwNb7cSFFBYzFICXwkM1Ot_9c3QT_ZwAAAP__LKFrkA">