<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63316>63316</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Instcombine incorrectly optimizes `fcmp uno`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DaniilSuchkov
</td>
</tr>
</table>
<pre>
After this commit: https://github.com/llvm/llvm-project/commit/e47b76a82a0300900dbf3c2d3a50552a76305a8c running `opt -passes=instcombine` on the following IR:
```
define i1 @test(i64 %arg) {
%sitofp = sitofp i64 %arg to float
%fmul = fmul float %sitofp, 0x7FF0000000000000
%fcmp = fcmp uno float %fmul, 0.000000e+00
ret i1 %fcmp
}
```
results in
```
define i1 @test(i64 %arg) {
ret i1 false
}
```
That's not correct because `fcmp uno` returns true if either argument is NaN and by IEEE-754 multiplication of infinity (aka `0x7FF0000000000000`) and 0 (`sitofp i64 %arg to float` with `%arg == 0`) is NaN. Alive2 points out exactly this case: https://alive2.llvm.org/ce/z/5rPFgH
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVF2PozYU_TXm5Woix4CBBx4yzaDOy6pq-weMuYTbNTayL7Ob_fUVJNOM2tVK1UaRuOB7zv04OjYp0cUjtqJ8FuU5MytPIbZn44ncH6udPoe3rA_DtT2NjBF4ogQ2zDOxyE8wMS9J5CehOqG6C_G09gcbZqE6597eH09LDH-hZaG6O1R1WFR9pU2tjMylbKQc-jG3ashNKctSmUrnsjS1hbh6T_4CQsuwMDwtJiVMIj-TT2zD3JNHoSUEDzwhjMG58GUDvP6-NSbPQp6Elvf__jrgSB6BjiAKyZhYqJp0AUKVJl6EakBUz7dU2D4m4jAuIPIz3MNHNnCA0QXDH_LHeXV79h7spw8aoX4B-bXqOvnx9xFt51utPVh9eDBsfDv-cEOhUM8PbETeZ7pR3Cevzt9dQcS0Ok5A_uc3dK87Gpfwx1X_nAwLVSXwgcGGGNEy9GjNmnAT-H3iTc-IvEafgOOKQCMg8YQRTLysM3oGSvDJfALjB-iv8Pry8vJUlQXMq2NaHFnDFDyEEciP5ImvIFRtPputznf2r-U21cYmt0Sh5Q-k1hK-EE-wo_YjkZ83yd55bs0d4OToDRUsgTwnCCsDfjWW3fVuJJPwvzYyO-iwOecQtm13FoXqvgnVlfG37vJrNrT50OSNybA96lpXum5Uk02txsKW6tjbY1M1VVkOxdhXdqxVpYexH01GrZIql_pYHOuyVM2hPg61qTfvldpU9SAKibMh90_1jFJasdV5ftSZMz269H5XxHY3d79ekiiko8TpAWNih-3rw6NA_q64u0JYmGb6hulfqmdrdO3_vlT2FpNQ3d7l3wEAAP__hrFyPg">