<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/72433>72433</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
InstCombine fails to reach fixpoint after 1 iteration
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:instcombine
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
topperc
</td>
</tr>
</table>
<pre>
This test file fails InstCombine with `LLVM ERROR: Instruction Combining did not reach a fixpoint after 1 iterations`
```
define i32 @not_last_operation(i32 %p, i32 %val) {
entry:
%tobool = icmp eq i32 %p, 0
%0 = zext i1 %tobool to i32
%1 = sub i32 2, %0
br i1 false, label %scalar.ph, label %vector.ph
vector.ph: ; preds = %entry
%2 = mul i32 20, %1
%ind.end = add i32 %val, %2
%.splatinsert = insertelement <4 x i32> poison, i32 %val, i64 0
%.splat = shufflevector <4 x i32> %.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
%.splatinsert2 = insertelement <4 x i32> poison, i32 %1, i64 0
%.splat3 = shufflevector <4 x i32> %.splatinsert2, <4 x i32> poison, <4 x i32> zeroinitializer
%3 = mul <4 x i32> <i32 0, i32 1, i32 2, i32 3>, %.splat3
%induction = add <4 x i32> %.splat, %3
%4 = mul i32 %1, 4
%.splatinsert4 = insertelement <4 x i32> poison, i32 %4, i64 0
%.splat5 = shufflevector <4 x i32> %.splatinsert4, <4 x i32> poison, <4 x i32> zeroinitializer
%broadcast.splatinsert = insertelement <4 x i1> poison, i1 %tobool, i64 0
%broadcast.splat = shufflevector <4 x i1> %broadcast.splatinsert, <4 x i1> poison, <4 x i32> zeroinitializer
br label %vector.body
vector.body: ; preds = %vector.body, %vector.ph
%index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%vec.ind = phi <4 x i32> [ %induction, %vector.ph ], [ %vec.ind.next, %vector.body ]
%5 = zext <4 x i1> %broadcast.splat to <4 x i32>
%6 = xor <4 x i32> %5, <i32 1, i32 1, i32 1, i32 1>
%7 = add nsw <4 x i32> %vec.ind, %6
%index.next = add nuw i32 %index, 4
%vec.ind.next = add <4 x i32> %vec.ind, %.splat5
%8 = icmp eq i32 %index.next, 20
br i1 %8, label %middle.block, label %vector.body, !llvm.loop !0
middle.block: ; preds = %vector.body
%9 = extractelement <4 x i32> %7, i32 3
br i1 false, label %exit, label %scalar.ph
scalar.ph: ; preds = %entry, %middle.block
%bc.resume.val = phi i32 [ 20, %middle.block ], [ 0, %entry ]
%bc.resume.val1 = phi i32 [ %ind.end, %middle.block ], [ %val, %entry ]
br label %for.body
for.body: ; preds = %for.body, %scalar.ph
%inc613.1 = phi i32 [ %bc.resume.val, %scalar.ph ], [ %inc6.1, %for.body ]
%inc511.1 = phi i32 [ %bc.resume.val1, %scalar.ph ], [ %inc5.1, %for.body ]
%10 = zext i1 %tobool to i32
%inc4.1 = xor i32 %10, 1
%inc511.1.inc4.1 = add nsw i32 %inc511.1, %inc4.1
%inc5.1 = add nsw i32 %inc511.1.inc4.1, 1
%inc6.1 = add nsw i32 %inc613.1, 1
%exitcond.1 = icmp eq i32 %inc6.1, 22
br i1 %exitcond.1, label %exit, label %for.body, !llvm.loop !3
exit: ; preds = %middle.block, %for.body
%inc511.1.inc4.1.lcssa = phi i32 [ %inc511.1.inc4.1, %for.body ], [ %9, %middle.block ]
%inc.2 = add nsw i32 %inc511.1.inc4.1.lcssa, 2
ret i32 %inc.2
}
!0 = distinct !{!0, !1, !2}
!1 = !{!"llvm.loop.isvectorized", i32 1}
!2 = !{!"llvm.loop.unroll.runtime.disable"}
!3 = distinct !{!3, !2, !1}
```
I haven't tried to reduce it yet.
CC: @nikic
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysWEtv2zoW_jX0hqggkXrECy8SOwEKdDBAMZhtQYlUzCktaUgqdfPrL_iQ9bBky7c3CBKZPOc7T348FlGKv1eM7UDyApLDhrT6WMudrpuGyWKT1_T37j9HrqBm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