<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/142765>142765</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missed optimization: equivalent expressions generate different assembly with extra load
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
gh228df
</td>
</tr>
</table>
<pre>
The Clang optimizer fails to generate equally efficient assembly for semantically equivalent expressions. The function sub_bytes() produces less optimal code than its logically equivalent counterpart sub_bytes_alt() or a version manually restructured to match optimized assembly.
Clang should recognize the algebraic equivalence of the expressions in sub_bytes() and optimize them the same way it does for sub_bytes_alt() or sub_bytes_asm().
---
Compiler Explorer: https://godbolt.org/z/rscej9nds
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxskk9vqzoQxT-N2YwSgYEkLFjk_WH3dm9fDfYAroxNPXba9NNfEaKk97YrS_b4zO8cHWQ2oyNqRf2XqP_JMMXJh3acpDzpIeu9vrb_TwR_W3Qj-CWa2XxSgAGNZYgeRnIUMBLQW0Jrr0DDYJQhFwGZae7tFQYfgGlGF43aZt6SuaBdh-hjCcRsvOM9rJuG5FQ03gGn_qW_RmIhT0I2sASvkyIGS8wbClpQXhPECR2YyGD9-H2F8slFCguG-BR9QRvvwj4AwoXCCgEzus1HII4hqZgC6dXojFFNjwT0w91e5GeRn7eAePLJagik_OjM50pGgHakPqBRTyhF4Ifb4xf_YL6bRqcfO9f5-faJcSZ4xyuYCNoTbwn_bO3LNc_b9R15t9vd2f28GEsB_v1YrA8URHmGKcaFRXkWshOyG73uvY17H0Yhu08hu8CKXhunedPIdFvqpmwwo7Y4Vk1eVkWRZ1Ore5kfi-I4yAZlUVZlfmyqU18oUoM-HIvMtDKXdX7IqyKvTmW-P9RDjVge-0N9qg5YiyqnGY3dW3uZV4LMMCdqi0oeD3VmsSfLtwJL6egdbq9CyrXPoV0_7fo0sqhyazjyUyaaaKn9zzDTI2Vcu7f6_7mjz75rMwwUfuv5u4kT0EcMCNajzlKw7R8xmjilfq_8LGS3ctyP3RL8K6koZHejZyG7u71LK38FAAD__413QcY">