<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118798>118798</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[InstCombine] Infinite loop when combining two `shl` instructions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
momo5502
</td>
</tr>
</table>
<pre>
The following sample triggers an infinite loop in instcombine:
```
@c = external constant i8
@c2 = external constant i8
define i16 @testfunc() {
entry:
%0 = shl i64 1, ptrtoint (ptr @c2 to i64)
%1 = shl i64 %0, ptrtoint (ptr @c to i64)
%2 = inttoptr i64 %1 to ptr
%3 = load i16, ptr %2, align 1
ret i16 %3
}
```
https://godbolt.org/z/WP6YvGjPq
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8Uk1r5DoQ_DXti8ggt-Svgw-TDH7klsODxzvKHtlWkCWv1M5s9tcv8jgsybILDTbqququplSMZnJat1A8QnHJ1EazD-3iF18UHLPeX9_bf2fNRm-tvxk3saiW1WpGwUyTDpEpx4wbjTOkmfV-ZSY9RBr80hunQZyB71Xyo_gZJB8YiAvT30kHpywbvIukHDFTH338K4Cfr3o0TjOTlwwkJx1p3NwAWAM2DKpH4GftKLzfF2AMsOC7ZJwtM6VkOeATWymQN44YYL1SYPfJ5BMCsPlg5p-YSepP5N-5dyPGEfkEOgTyBFwpfKDEjrJeXZOlQ32np39lzeRYvoODprtrLEQ6RXX5el1-nonWmJxjB9hN_tp7SycfJsDuB2D330v5_9s_ry_fgJ-zayuujWhUptu8EkJyWdU8m1s5iKFEVCPWpaxzkQ-6kkWPfTM2UpeYmRY5yhx5kYu8Ec2JKy6w4o0UsqlGVCC5XpSxJ2vfljQ-MzFuus3zumrqzKpe27hnD9HpG9u7gJiiGNpEeui3KYLk1kSKv2TIkN1D--wiPR1JKy7s-VMSb7N27J7DlFy6eQYlj7OFku8ZDdtAxruYbcG2X25maN760-AXwC7NPT4Pa_CveiDAbt82AnaHnbcWfwYAAP__UMb8xw">