From 28b15148fb9ded8c1038a2437e11d8489f8bb1c8 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 10 Apr 2021 22:17:35 +0200 Subject: [PATCH] [IVUsers] Check LoopSimplify cache earlier (NFC) Check the cache before calling isLoopSimplifyForm(). Otherwise we'd always perform the check for the innermost loop and only skip it for dominating loops. --- lib/Analysis/IVUsers.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Analysis/IVUsers.cpp b/lib/Analysis/IVUsers.cpp index 9432696b5a2..db6cff72064 100644 --- a/lib/Analysis/IVUsers.cpp +++ b/lib/Analysis/IVUsers.cpp @@ -101,12 +101,12 @@ static bool isSimplifiedLoopNest(BasicBlock *BB, const DominatorTree *DT, BasicBlock *DomBB = Rung->getBlock(); Loop *DomLoop = LI->getLoopFor(DomBB); if (DomLoop && DomLoop->getHeader() == DomBB) { - // If the domtree walk reaches a loop with no preheader, return false. - if (!DomLoop->isLoopSimplifyForm()) - return false; // If we have already checked this loop nest, stop checking. if (SimpleLoopNests.count(DomLoop)) break; + // If the domtree walk reaches a loop with no preheader, return false. + if (!DomLoop->isLoopSimplifyForm()) + return false; // If we have not already checked this loop nest, remember the loop // header nearest to BB. The nearest loop may not contain BB. if (!NearestLoop)