[llvm] 24d1877 - [LoopFusion] Reorder dependence checks to reduce compile time (NFC) (#206275)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 11:56:02 PDT 2026


Author: Ehsan Amiri
Date: 2026-06-30T14:55:57-04:00
New Revision: 24d187791ca014b01781ba6671985b95e9131130

URL: https://github.com/llvm/llvm-project/commit/24d187791ca014b01781ba6671985b95e9131130
DIFF: https://github.com/llvm/llvm-project/commit/24d187791ca014b01781ba6671985b95e9131130.diff

LOG: [LoopFusion] Reorder dependence checks to reduce compile time (NFC) (#206275)

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 012a54de173e7..51874366d147f 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -1192,6 +1192,16 @@ struct LoopFuser {
     assert(FC0.L->getLoopDepth() == FC1.L->getLoopDepth());
     assert(DT.dominates(FC0.getEntryBlock(), FC1.getEntryBlock()));
 
+    // Walk through all uses in FC1. For each use, find the reaching def.
+    // If the def is located in FC0 then it is not safe to fuse.
+    for (BasicBlock *BB : FC1.L->blocks())
+      for (Instruction &I : *BB)
+        for (auto &Op : I.operands())
+          if (Instruction *Def = dyn_cast<Instruction>(Op))
+            if (FC0.L->contains(Def->getParent())) {
+              return false;
+            }
+
     for (Instruction *WriteL0 : FC0.MemWrites) {
       for (Instruction *WriteL1 : FC1.MemWrites)
         if (!dependencesAllowFusion(FC0, FC1, *WriteL0, *WriteL1)) {
@@ -1211,16 +1221,6 @@ struct LoopFuser {
           return false;
         }
 
-    // Walk through all uses in FC1. For each use, find the reaching def. If the
-    // def is located in FC0 then it is not safe to fuse.
-    for (BasicBlock *BB : FC1.L->blocks())
-      for (Instruction &I : *BB)
-        for (auto &Op : I.operands())
-          if (Instruction *Def = dyn_cast<Instruction>(Op))
-            if (FC0.L->contains(Def->getParent())) {
-              return false;
-            }
-
     return true;
   }
 


        


More information about the llvm-commits mailing list