[llvm] [LoopInterchange] Also look at lcssa phis in outer loop latch block (PR #160889)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 14 10:31:07 PDT 2025


kasuga-fj wrote:

If I understand @Meinersbur 's comments correctly, they’re suggesting looking for single-input PHIs and bailing out if there’s one in a BB which is not `InnerExit`. So I imagined adding something like the following to `tightlyNested`.

```cpp
for (BasicBlock *BB : OuterLoop->blocks()) {
  if (InnerLoop->contains(BB))
    continue;
  if (BB == InnerExit)
    continue;

  for (PHINode &Phi : BB->phis())
    if (Phi.getNumIncomingValues() != 1)
      return false;
}
```

https://github.com/llvm/llvm-project/pull/160889


More information about the llvm-commits mailing list