<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112149>112149</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
LLVM at -Oz can't remove a loop that can be removed at -O3
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dcci
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/o7q1cjez1
```
void f() {
int arr[5] = {1, 2, 3, 4, 5};
for (int k = 0; k < 5; k++) {
arr[k] *= 2;
}
}
```
I haven't looked closely, but I suspect -O3 can simplify this loop as it unrolls and later finds out that the stores are dead. -Oz doesn't do that. IIRC at some point there was a loop re-roller that got removed which could potentially catch these cases.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxcU81u4zwMfBr6QiSQ6b_k4EPTIECAfijwHfYuS3SsVrG8kpwiffqF7Gx3u4Awpi0NhxxTMgRzGZlbqA5QHTM5x8H5Vitlss7pezvEOAUonoBOQKeL052zcev8Bej0CXRyzc9cvfFnDuII4umBtXis5fXmjMYeaAe0R2gO61dEM0aU3kN1qKA6IhTHtJsDPSMlKBKUCSpojlB8EXvnEWiX-O8LTUBxWMJ0NIVAh2V908OH2vuiRk-JSX-lTSJr_V_B90ZWPOMgbzwCNRGtc--sUVkX2N5Tqd0c8YxhDhOriJvXApUcMZjrZE1_xziYkFgTyoAm4jx6Z21AOWq0MrLH3ow6oJsjxkEmYAzReQ4oPaNmqbe4ef1E7TisRWi3HN3i-fz_M8qIwV0ZJ5f8iQN7xg8ZUK6ynjdJkf2a_uIier66G2v8GIwaULnZapxc5DEaae0dlYxqSJkCo5KBwzbTbaH3xV5m3OYN7XZlLYTIhrYXVdc1-a4vG26oVrUUspSc12Inue7LzLQkqMxFXuR7IYTYclntVK1VL6kQdbeHUvBVGru19nZNg5aZEGZu85zycp9Z2bENy7gSjfyByy4Qpen1bSJtuvkSoBTWhBj-pIkmWm5fXn78lyxKDiq5-rf2_9ugxZb0zzr-cmYhFNns7b8XwsRh7rbKXYFOSerx2EzevbGKQKelwAB0enRwa-lXAAAA__9h9ArW">