<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68712>68712</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed optimization: reuse of constant in a register
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dvyukov
</td>
</tr>
</table>
<pre>
```
int foobar(int x) {
return x < 200 ? x : 200;
}
```
clang generates:
```
foobar(int):
cmp edi,0xc8
mov eax,0xc8
cmovl eax,edi
ret
```
https://godbolt.org/z/37GYzc9vb
gcc reuses the const and generates 4 bytes less code:
```
foobar(int):
mov eax,0xc8
cmp edi,eax
cmovle eax,edi
ret
```
https://godbolt.org/z/T38r34b3P
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysUk2PmzAQ_TXDZbSRsfkIBw7ZjeipUg-99GjsCXFr7Mg2NMmvryDZbrbaHipVQph5M-a9NzMyRjM4ohbKZyj3mZzS0YdWz5fph5-z3utLCxW7P2wPbGdcwoP3vQzAt0twBt4g1M-3NLAmUJqCwzOCeEHOGILo1mi3RCBeK-v9_eM9we2trHQDDuQoyEQRxO7D4kclwJvfZajGE5I2wF_YWW3v4OhnRESS5_e4Gv1sX_Hl1g0OlD4kPaZ0WhXxDng3eN17mzY-DMC7K_BO1J--XVUz94-GBqUw0BQpYjoSKu9iQun0m0cssL8sp6UYUXlN_-z67wZPK742ZMk--Kb_5vur2AZR9OJLpluhG9HIjNq8aqqmqAUT2bEtC9kIWSmlqdRNzsuSMam3UgjRHxTnmWk54yJnOcuLvGRiQ1oeioblB9WLOq9yKBiN0tiNtfO4cGcmxonaalvnPLOyJxvXbebc0U9ck8D5styhXe489dMQoWDWxBTf_pJMstR-NjGSRn9KZjRXmYx3y9quc0N_uE1NuoTGocRAg4mJQjYF2_7RHJOOU79RfgTeLST34-kU_HdSCXi3SovAu1X6rwAAAP__4_AHYQ">