[llvm] [LoopNestAnalysis] Change the definition of perfect loop nest (NFC) (PR #206077)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 03:50:11 PDT 2026
================
@@ -332,94 +314,21 @@ static bool checkLoopsStructure(const Loop &OuterLoop, const Loop &InnerLoop,
InnerLoop.getExitingBlock() != InnerLoopLatch || !InnerLoopExit)
return false;
- // Returns whether the block `ExitBlock` contains at least one LCSSA Phi node.
- auto ContainsLCSSAPhi = [](const BasicBlock &ExitBlock) {
- return any_of(ExitBlock.phis(), [](const PHINode &PN) {
- return PN.getNumIncomingValues() == 1;
- });
- };
-
- // Returns whether the block `BB` qualifies for being an extra Phi block. The
- // extra Phi block is the additional block inserted after the exit block of an
- // "guarded" inner loop which contains "only" Phi nodes corresponding to the
- // LCSSA Phi nodes in the exit block.
- auto IsExtraPhiBlock = [&](const BasicBlock &BB) {
- return &*BB.getFirstNonPHIIt() == BB.getTerminator() &&
- all_of(BB.phis(), [&](const PHINode &PN) {
- return all_of(PN.blocks(), [&](const BasicBlock *IncomingBlock) {
- return IncomingBlock == InnerLoopExit ||
- IncomingBlock == OuterLoopHeader;
- });
- });
- };
-
- const BasicBlock *ExtraPhiBlock = nullptr;
- // Ensure the only branch that may exist between the loops is the inner loop
- // guard.
+ // Ensure the outer loop header flows directly into the inner loop preheader
+ // through at most empty (unconditional) blocks. Loop-invariant guards that
+ // previously branched from the outer header to the latch are removed by
+ // SimpleLoopUnswitch run, so no conditional branch is expected here.
----------------
kasuga-fj wrote:
I don't think this comment is very useful. Generally speaking, if you're just deleting existing code, it's not particularly important what was there before.
https://github.com/llvm/llvm-project/pull/206077
More information about the llvm-commits
mailing list