[llvm] 3db1cf7 - [LoopFusion] Use the LoopInfo::isRotatedForm method (NFC).

Kit Barton via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 12:05:01 PST 2019


Author: Kit Barton
Date: 2019-12-18T15:04:25-05:00
New Revision: 3db1cf7a1e6731a02b475bdda05ea2d38f3e5ea8

URL: https://github.com/llvm/llvm-project/commit/3db1cf7a1e6731a02b475bdda05ea2d38f3e5ea8
DIFF: https://github.com/llvm/llvm-project/commit/3db1cf7a1e6731a02b475bdda05ea2d38f3e5ea8.diff

LOG: [LoopFusion] Use the LoopInfo::isRotatedForm method (NFC).

Loop fusion previously had a method to check whether a loop was in rotated form. This method has
been moved into the LoopInfo class. This patch removes the old isRotated method from loop fusion,
in favour of the new one in LoopInfo.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopFuse.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index a7f4242853fc..b17b243d8a30 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -167,14 +167,8 @@ struct FusionCandidate {
                   const PostDominatorTree *PDT, OptimizationRemarkEmitter &ORE)
       : Preheader(L->getLoopPreheader()), Header(L->getHeader()),
         ExitingBlock(L->getExitingBlock()), ExitBlock(L->getExitBlock()),
-        Latch(L->getLoopLatch()), L(L), Valid(true), GuardBranch(nullptr),
-        DT(DT), PDT(PDT), ORE(ORE) {
-
-    // TODO: This is temporary while we fuse both rotated and non-rotated
-    // loops. Once we switch to only fusing rotated loops, the initialization of
-    // GuardBranch can be moved into the initialization list above.
-    if (isRotated())
-      GuardBranch = L->getLoopGuardBranch();
+        Latch(L->getLoopLatch()), L(L), Valid(true),
+        GuardBranch(L->getLoopGuardBranch()), DT(DT), PDT(PDT), ORE(ORE) {
 
     // Walk over all blocks in the loop and check for conditions that may
     // prevent fusion. For each block, walk over all instructions and collect
@@ -261,12 +255,6 @@ struct FusionCandidate {
                : GuardBranch->getSuccessor(0);
   }
 
-  bool isRotated() const {
-    assert(L && "Expecting loop to be valid.");
-    assert(Latch && "Expecting latch to be valid.");
-    return L->isLoopExiting(Latch);
-  }
-
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   LLVM_DUMP_METHOD void dump() const {
     dbgs() << "\tGuardBranch: "
@@ -320,7 +308,7 @@ struct FusionCandidate {
       return reportInvalidCandidate(NotSimplifiedForm);
     }
 
-    if (!isRotated()) {
+    if (!L->isRotatedForm()) {
       LLVM_DEBUG(dbgs() << "Loop " << L->getName() << " is not rotated!\n");
       return reportInvalidCandidate(NotRotated);
     }


        


More information about the llvm-commits mailing list