<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/88550>88550</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
x * 20 * y * z / 20 is not optimized
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
apolukhin
</td>
</tr>
</table>
<pre>
Consider the example:
```
int test(int x, int y, int z) {
return x * 20 * y * z / 20;
}
```
trunk version of clang with -std=c++26 -O2 flags produces the assembly:
```
test(int, int, int): # @test(int, int, int)
imul edi, esi
imul edi, edx
shl edi, 2
lea eax, [rdi + 4*rdi]
cdqe
imul rax, rax, 1717986919
mov rcx, rax
shr rcx, 63
sar rax, 35
add eax, ecx
ret
```
However, a more optimal assembly is:
```
test(int, int, int):
imul edi, esi
mov eax, edi
imul eax, edx
ret
```
Godbolt playground: https://godbolt.org/z/n1nEecq93
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclN1u6ygQx59mfDNKhMf468IXycl6926fARsSswebFHCa5OlXtpO0jdpKPchisP7DwG8GjfBeHwalKki3kO4iMYbOukocrRl_d3qIGisv1S87eC2Vw9ApVGfRH42CZANsB2wDGbt9868eAgblA1AxLc9Av3BaXO6LK1CJkG8Xd0REp8LoBjwj0AaJzeYyz1cEqpEYJDd3yHefnhrcOPzGk3Je2wHtHlsjhgO-6tDhygcJya4F2gJtKcPVv4R7Iw4ej87KsVV-BhPeq74xl6_I3qhuKA9TQjKDfDmAEgTOvovwyMY0dD-aySqpJxfl9fe6PH_UfTfLd50-qkaJRRVzdSDdOqkRaIscaOOkhvSWZWzli_r8aLdsvpk4j_OyyMr4CaS3p9m69uG96L5z74UseQIQN3kJn6QfZSHlewLVPvE7FT4t4TL_Y1_VSblpp8DeOoX2GHQvzOMJoPZ_9gp-VsYpO3cE-VWJ7_qPEP-2srEm4NGIy8HZcZDTE-1COM5gVAPVh8Vnbd0BqL4C1UM8_KXalzKJZJXIMilFpKo4j6nkWZHyqKv4npcNl3lSsDYrYiF5zpq2aSlPGp5lItIVMeKMxxQXCY_5WohG8JIle1m2rNi3wJnqhTZrY079dHakvR9VVRRpyiIjGmX83I2IBvWKswhEU3Ny1bRn1YwHD5wZ7YN_ixJ0MKr6poeg9jjYsNRaX5WMRmeqp5To0I3NurU9UD2FvpnV0dn_VBuA6vlCHqieL_x_AAAA__9JvW7z">