<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70561>70561</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
InstCombine:dubious optimization of a - a * 0.0 when a might be inf
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:instcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jayfoad
</td>
</tr>
</table>
<pre>
InstCombine optimizes:
```
define float @f(float %a) {
bb:
%z = fmul float %a, 0.0
%r = fsub reassoc nsz float %a, %z
ret float %r
}
```
to:
```
define float @f(float %a) {
bb:
ret float %a
}
```
This seems dubious to me because if %a is inf, the result should be nan. There are no "ninf" or "nnan" flags in the code. Is there something about the "reassoc" and "nsz" flags that somehow allows this optimization?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU8FuozAQ_RpzGRUZE0g4cEgbReq9PzCGAVwZu_KYrZqvX9lJN9nVak8rIaHHvPc8D88gs5kdUS-aZ9GcCtzi4kP_jl-Tx7HQfvzqXx3HF79q4wj8RzSruRCL-ijkScijaOXtyXCkKfEm6zGC2MlJqMMNqAaF6kDsn69UrX-ZQKpeQNQnmNbNwqPiBWQpH2jhSuNNQyBk9gM4vvwhSXbfmkDxXg23rvenv7Yf_f8O9tvp-O_T3xbDwEQrw7hp4zeG6GEl0DTgxgRmyi5gGIybUtC4EATizUbgxW92BE3g0JXwtlAgwEDgPAilXFYo8CEjhy6hyeKczLLR4Ecq4ZUTCATsV4qLcTOg9lvMFKHU7a8nNboxm_Hl7hUXjFm6-E9Aa_1n-mb4e3YwGu9EfS7Gvh67usOC-qrtDk3VVlIWS7-XY9XoqpWyqTpsSCm576qpJdJjKyddmF5JVVdSHaqDrOpDOQzVrla7gfSosKs7sZO0orGltT_W0oe5MMwb9XvZtFVhUZPlPPFKJYaoj8ZxHK4zLpRKmxD6VHrS28xiJ63hyHe7aKKlx8UQ9fH7xh5jgp8A4QkQhDqmOYbPhRwgrGZeYroq46ZiC7ZfYvzIS6XOQp1nE5dNl4NfhTrnFq-vp4_g32mIQp1zIhbqnEP9DAAA__8IRyQz">