[llvm] 8de2f1f - [IVUsers] Check LoopSimplify cache earlier (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 10 13:59:38 PDT 2021


Author: Nikita Popov
Date: 2021-04-10T22:58:13+02:00
New Revision: 8de2f1ff79aa2a8a72b8c44ea70b48aa9f282ae5

URL: https://github.com/llvm/llvm-project/commit/8de2f1ff79aa2a8a72b8c44ea70b48aa9f282ae5
DIFF: https://github.com/llvm/llvm-project/commit/8de2f1ff79aa2a8a72b8c44ea70b48aa9f282ae5.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Analysis/IVUsers.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/IVUsers.cpp b/llvm/lib/Analysis/IVUsers.cpp
index 9432696b5a26..db6cff720642 100644
--- a/llvm/lib/Analysis/IVUsers.cpp
+++ b/llvm/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)


        


More information about the llvm-commits mailing list