| Issue |
203466
|
| Summary |
[LoopInterchange] Assertion failure with multi-entry PHI in inner preheader
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
madhur13490
|
LoopInterchange assumes that PHIs in the original inner loop preheader have
exactly one incoming value. This is not true when the outer header has duplicate
CFG edges to the inner preheader. The IR verifier accepts a PHI with matching
duplicate entries from the same predecessor, but LoopInterchange asserts while
eliminating the preheader PHI.
Reproducer:
```llvm
; RUN: opt -passes=verify -disable-output %s
; RUN: opt -passes=loop-interchange -loop-interchange-profitabilities=ignore \
; RUN: -disable-output %s
define void @f(ptr noalias %A, i1 %c) {
entry:
br label %outer.header
outer.header:
%i = phi i64 [ 0, %entry ], [ %i.inc, %outer.latch ]
br i1 %c, label %inner.ph, label %inner.ph
inner.ph:
%p = phi i64 [ 42, %outer.header ], [ 42, %outer.header ]
br label %inner
inner:
%j = phi i64 [ 0, %inner.ph ], [ %j.inc, %inner ]
%gep = getelementptr inbounds [10 x [10 x i32]], ptr %A, i64 0,
i64 %j, i64 %i
store i32 0, ptr %gep, align 4
%j.inc = add i64 %j, 1
%ec.j = icmp eq i64 %j.inc, 10
br i1 %ec.j, label %outer.latch, label %inner
outer.latch:
%i.inc = add i64 %i, 1
%ec.i = icmp eq i64 %i.inc, 10
br i1 %ec.i, label %exit, label %outer.header
exit:
ret void
}
```
Disclaimer: This is AI generated test.
```opt -passes=loop-interchange -loop-interchange-profitabilities=ignore -disable-output repro.ll
bool (anonymous namespace)::LoopInterchangeTransform::transform(
ArrayRef<llvm::Instruction *>, ArrayRef<llvm::Instruction *>):
Assertion `P.getNumIncomingValues() == 1 &&
"Expected single-incoming PHIs in inner loop preheader"' failed.
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs