<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54191>54191</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[scev] Loop unrolling blocked by finite loop handling of nonstrict inequalities
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mtrofin
</td>
</tr>
</table>
<pre>
[scev-test.zip](https://github.com/llvm/llvm-project/files/8182815/scev-test.zip)
See https://reviews.llvm.org/D118090
To repro, unzip the attachment, then:
```
opt -mtriple=x86_64-linux -mattr=+64bit,+sse3,+ssse3 -passes="require<scalar-evolution>,loop-unroll" /tmp/good-test.ll -scalar-evolution-finite-loop=0 -S -o /tmp/no.ll
opt -mtriple=x86_64-linux -mattr=+64bit,+sse3,+ssse3 -passes="require<scalar-evolution>,loop-unroll" /tmp/good-test.ll -scalar-evolution-finite-loop=1 -S -o /tmp/yes.ll
diff /tmp/no.ll /tmp/yes.ll
```
This is causing ~20% regression in an eigen benchmark. The .ll is extracted from there - it could have probably be further reduced, but I wasn't successful.
The interesting loop is the one at block `863`. See `SCEVExpander::isHighCostExpansion`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVEtv2zAM_jX2hbBhy3ZiH3JokwwbsFuLXQfJpmOtiuTpkSb79aOcdW26XXYcIEgUxcdH6ROFGS6bpLl3PZ4yj87nP-ScNLuEtZP3s0uqu4R9oHGQfgoi782RNkqdXpZstuYb9p62o1ToaG3LlrVlQ9JtVNYlxS4p7q7zAyLcprB4kvjs8hg2N_ZAql1ZtkVXvPV7NGCRkiZsC0FTXPATAvee99MRtY960ugY9o1bsip-jWVrZg_Z0Vs5K0yq3bldfV3VmZI6nElP0SxpE3a_qoWMIUl0DqsXiUTIZk6rW-yYxe9BWgq1dT1X3GZ4Mip4aQjHnryUMXMWtDVKkTVQaf44x2s1ZrjekFKQvffNRqmlxyx6U54CsgfIzKu3NtHtP66ofF_RBd1rSdd5kOP4R8m39n994l90maQDGj0PTuoDJOs9KxLWEIkOFp0jTCA1cA0oD6hBoCYecfuUwyPxKiYjbzx7y3uPA4zWHCO_LEIG0kNvghpg4icEIqXgQl0oBozBRiPKMoQeh0hKETx8gmfudMLWHlzoe8o_BpXf4kXC4ym-8xFvvKiIIJLc6Eh0EMr0T0B1tquK5hziVyLhYbv_sj_PXA9oI_urO-k-ysO0Nc4v-lgs2aXDphq6quOpl17hy_enXw-fY7bro8bkSyYqWlzg-m5XOBOlWM7NCNpoR6TrPaEmxnAlvUSXBqs2_9xApHNh6SBNXXZlOm1wGOuBFc26a5mIbaUvyqbpcKyqgVcCU8UFKhcrIPSp3LCCsaIq6qJiNVvnQoiy6cRqxJoj64ekLvDIpfrdYlK7WTCIcHB0qKTzr_0npd8gDxrxJT4PfjJ2Q5_M0HWkC9zNgvUngqawsA">