Issue 204065
Summary [LoopInterchange] Assertion failure when outer header has more than two predecessors and one of them branches via `indirectbr`
Labels loopoptim, crash-on-valid
Assignees kasuga-fj
Reporter kasuga-fj
    ```llvm
; RUN: opt -passes=loop-interchange --loop-interchange-profitabilities=ignore

define void @f(i1 %c, i32 %x, i32 %y, ptr %A) {
entry:
  br i1 %c, label %entry.0, label %entry.1

entry.0:
  br label %outer.header

entry.1:
  indirectbr ptr blockaddress(@f, %outer.header), [ label %outer.header ]

outer.header:
 %i = phi i64 [ 0, %entry.0 ], [ 0, %entry.1 ], [ %i.next, %outer.latch ]
 %sel = phi i32 [ %x, %entry.0 ], [ %y, %entry.1 ], [ %sel, %outer.latch ]
 br label %inner

inner:
  %j = phi i64 [ 0, %outer.header ], [ %j.next, %inner ]
  %gep = getelementptr inbounds [256 x i32], ptr %A, i64 %j, i64 %i
  store i32 %sel, ptr %gep
  %j.next = add i64 %j, 1
  %ec.j = icmp eq i64 %j.next, 256
  br i1 %ec.j, label %outer.latch, label %inner

outer.latch:
  %i.next = add i64 %i, 1
  %ec.i = icmp eq i64 %i.next, 256
  br i1 %ec.i, label %exit, label %outer.header

exit:
  ret void
}
```

```
opt: /home/containeruser/llvm-project/llvm/lib/Transforms/Scalar/LoopInterchange.cpp:1265: bool {anonymous}::LoopInterchangeLegality::checkInductionsAndReductions(llvm::Loop*): Assertion `PHI.getNumIncomingValues() == 2 && "Phis in loop header should have exactly 2 incoming values"' failed.
```

Disclosure: The test case is AI generated
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to