<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/91957>91957</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Miscompile with opt -passes="loop-unroll,loop-mssa(licm,indvars)" -unroll-count=4
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mikaelholmen
</td>
</tr>
</table>
<pre>
llvm commit: e76b257483e6c
Reproduce with:
```opt -passes="loop-unroll,loop-mssa(licm,indvars)" -unroll-count=4 bbi-95405.ll -S -o -```
The input function returns 32768, but after running the passes as above we get
```
define i16 @foo() {
entry:
br label %loop
loop: ; preds = %loop, %entry
br i1 false, label %loop, label %end, !llvm.loop !0
end: ; preds = %loop
ret i16 8192
}
!0 = distinct !{!0, !1}
!1 = !{!"llvm.loop.unroll.disable"}
```
So now the function returns 8192 instead.
If I extract the IR after loop-unroll or licm and run the rest of the passes instead I get the correct result.
[bbi-95405.ll.gz](https://github.com/llvm/llvm-project/files/15294896/bbi-95405.ll.gz)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVM2O4zYMfhr6QsSwKSu2Dz7MTBBgDr3s9gVkm07UypIhyTPdPn0h253JbNFDgQJBEoo_H8nvA1UI-maZO5DPIC-ZWuPd-W7Wvys2d2dmtlnvxh-dMW8zDm6edQTxhFyfe5J11Qg-D1BcoHj6xot34zowvut4B_G0P8O52D9uiXhaVAgcQFyAyDi3nFbrnTFAL5s1h6CAGqOHGehF2_FN-QDUAhEeoafBrTaCuFTY9_rUyqqQuTF4-o4nh6cPuAN9-_71zqjtskacVjtE7Sx6jqu3AQXV5wboBfs1opoie_SrtdreMN4Z935RBVS9e2N8Z7xx_Gmy3Rx50pZRl2eEqpicA2qAWoT6eQ9gG_2Pj70g9h6N6tkgkEzTP3a82eIJQTzj4nkMCOLyEUgv6e9e77OYLnFSJnByfy38-MB23PPLRGme_Mn4sq8U86_gB6DnuM3alC0dufXlsUgquiWOOkRth5hg0jIS2N5B-ZlCZXmgHDFJIH83mO_U56MOqjcMRJ-JX0n47tC69426f1CdOkVtQ2Q15o-dvk74ivxH9GqIW-rrt0MKDxJF5zHpEpUdk0S2QM8hopsepXIA4GsSyuYYnPc8xBS8mvgFGeTzo4jz258gL0DNPcYlJKnQFeh60_G-9vngZqBrWsrxc1q8-42HCHSdtOEAdC0ltVXTnoGuPxemdsfMxk6MrWhVxl1Zl_JcSFlV2b1TVIxqEqKpRVEOLdWNaETJfVGo5qxqmemOCqoKWYpSFLISuRiorFQ_jW0z1I0coCp4VtrkG3PO3zIdwspdW7ayzjYJhu3SEFl-x82ZyJSXzG8X5tSvtwBVYXSI4bNK1NFw94sOg5sXbfYLg___QclWb7r_vPttjLT8bcy_AgAA__8ADZe4">