<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59834>59834</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Worse optimization compared to GCC
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
joemalle
</td>
</tr>
</table>
<pre>
Clang compiles this function into 24 instructions compared to 17 for GCC (with `-O3 -ffast-math`)
```
void result(double a, double b) {
bool cond = (a == 0 & b == 0.0);
double ret = 0.0;
if (cond) [[likely]] {
external1();
}
external2(!cond);
}
```
https://godbolt.org/z/jWfszY9zE
I think the problem is that LLVM tries to apply De Morgan's law to the expression without realizing it won't be able to remove the original.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxcU09vpD4M_TTmYs0IEv4eOLTDj-ontdrbVntMwEDaQFASOu18-lXotNt2NAIHv_ds-TnCOTUuRDVkt5A1kdj8ZGz9ZGgWWlMkTf9Wn7RYRuzMvCpNDv2kHA7b0nllFlSLN8hSVIvzdtu_uR0rLPXoDSYFDsbi3emEwMqz8hNCHh9-cTwMg3D-MAs_QR4DqyBuIL4J8ft_P74Y1aMlt2kPrOzNJjWhAHbCayyBVQjF7TscEVEao7EzS4_Am1BVhCDEMQLLUX4ej3tZ_sG9Klry-JHmX3TVEMSC8F4yjOxWq2fSb5A1kDXfuwg_evVkF6ETYOW3SlA01-gDwnZIclX_RH4Cf4xl8n51wG-AtcDa0fTSaH80dgTWXoC1T4-Du_ypLv9d2fvz_2De8ox-IlytkZpmVMFR4fH-_vcDequCwwbFuuo3bAgfjB3FAqxwqMU5pAKZXldLzoUFCI6azaMlodVFLSMqj2cTKB4loQgT9QYtzeaFdraxalSL0Meor3lf8UpEVCd5wcq8TLIymuoh5TylLOOVzPtByqLs0jzNqUv6oqOijFTNYsbjJE5ZwrOsPPaxKDgXsSj6eCBZQhrTLJQ-av0yh7lEyrmN6qwqeRppIUm7fesZW-iMexIYC5fA1oFzkNvoII21ct79U_HKa6ofjXWEZvVqVhexX4SvO393OkWb1fUPk5SfNnnszAysDYLX12G15ok6D6zd23DA2r3NvwEAAP__FGAYyA">