<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59451>59451</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
InstCombine: incorrect select + fast-math swap
</td>
</tr>
<tr>
<th>Labels</th>
<td>
miscompilation,
llvm:instcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nunoplopes
</td>
</tr>
</table>
<pre>
The transformation below is from `InstCombine/select-binop-foldable-floating-point.ll`:
```llvm
define float @select_fadd_swapped_fast_math(i1 %cond, float %A, float %B) {
%C = fadd fast float %A, %B, exceptions=ignore
%D = select i1 %cond, float %A, float %C
ret float %D
}
=>
define float @select_fadd_swapped_fast_math(i1 %cond, float %A, float %B) {
%C = select i1 %cond, float -0.000000, float %B
%D = fadd fast float %C, %A, exceptions=ignore
ret float %D
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source
Example:
i1 %cond = #x1 (1)
float %A = #x7f900001 (QNaN)
float %B = #x027effff (0.000000000000?)
Source:
float %C = poison
float %D = #x7f900001 (QNaN)
Target:
float %C = #x80000000 (-0.0)
float %D = poison
Source value: #x7f900001 (QNaN)
Target value: poison
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzElMuOozoQhp-m2FhEUFwSFiyS0JHOpo9On95HBtuJR8ZGtunL248MuXV6pnt2E0UkmKrff32UizonD5rzGooNFE1ER380ttajNoMyA3dRa9h7_XzkxFuqnTC2p14aTVquzCuRjghregJl8o92fmv6VmoOuHNc8c7HrdRmiIVRjLaKx0IZ6qU-xIOR2i-UgjKBbA1JA8n5WibzV6mXfl5iXEjNyZRMIE9m7b2gjO3dKx0GzvaCOr_vqT8CrmRKAIvOaAa4Padhsf5wtwGsCCw38xYkLG0JZA0JsiTI3WXOOVvC3zo-BAQOskYetLH8RqOZNGaH5I-MbM_Zlt9s2ZxoLM9_sgayh7_B44ta4mSRTJ87pXscv0C6PSFdf4P0SyjPH1uSGe404NKTF26leAdMbzvr4enp3yfI1uSZ2gP3oXd7YzkZjHRGm9ERf6SaODPajn9IfKP9oPilUa8opuoAs7ewskoBqzniyvgSsRRVIDUF_vdIHz_Hbi6xCS65EEKE2DPiE-hsd0mcr__Pds_eroAntbm2u0fN96ZOfCdQv9MOAquTryAQuuFzVc0nH7Nj8kLVGHx_beT0ri7Bt0KXURGxOmNVVtGI12m5TJbVKk3L6FgXlNG2QM4EWwkuclGlWVoy0YmStSuKkawxQUwxTRGzIk0XeV62bZ6kCStYXuUM8oT3VKpFGEcLYw-RdG7kdVHlRRop2nLlpuGJ2EvXmX6QaupGQATcAuI0x7K11M535_GIYdbaOjyK2_HgIE-UdN5dd_HSK17fztRsTaTujLXhNJ4OJeBmOldxOOkknP1otKo-ej-48NpwB7g7SH8c20VnesDd5Gb-iQdrfvDOA-6mmhzgbirrZwAAAP__MdXGOQ">