<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/135829>135829</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
two-instruction pass actually worsens codegen
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AZero13
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/vrexqnWoe
There is nothing wrong with:
add edi, esi
mov eax, edi
sub edi, edx
cmovnc eax, edi
ret
But the two-address pass makes it:
lea eax, [rdi + rsi]
xor ecx, ecx
cmp eax, edx
cmovae ecx, edx
sub eax, ecx
ret
which is actually less optimal.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxcUsGO4yoQ_Bp8QYlwY4-TA4fkjfwFT1ppbxh6bXYxZGmcZPbrV9hRJjs-GKmpqq6iWxO5MSAq1p5Z-17pJU8xqdN3TLGW1RDth5pyvhCTJwY9g36Mdog-72MaGfR_GPTXhPff4VtEJk5MnP6fMCF3xEPMkwsjv6VY_i5PRUScONfWcrSOwX8cya2lOV456vtasluJluGJsve1ZOZ4DeYrMGHeWp-XzPOEPN_iTlubkIhfNBGf9S8k7vJmYCVtn0e9ng9F1p6TdZzBmSdyrH1_gd5j2qBma27uL5dmvrzqPPwWuxo_KfaVUuK9Uv7Re0a6Tc5M5TW1yYv2_oP7kipespu13_PKKmmP8qgrVHXXNF0juqOsJoWyM7rutICus2KwAms8iA6wNTUIPFROgYBWNHVbH2pZy72VrXkD-dZ12rY_TMMagbN2fu_9dS7zrhzRgqqW7QGOldcDeloXByDgja-3DKDsUVKFtBuWkVgjvKNMnzLZZY-qDMkFymkx2cWwDeqZ8hYTYSBuosURQ7Uk_3URXZ6WYW_izKAv2o9jd0nxJ5rMoF8dEYP-Yfmq4G8AAAD__xvZ5lw">