[llvm] [DependenceAnalysis] Extending SIV to handle fusable loops (PR #128782)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Sep 18 08:49:34 PDT 2025
    
    
  
================
@@ -3686,6 +3775,46 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
     }
   }
 
+  // Establish loop nesting levels considering fusable loops as common
+  establishNestingLevels(Src, Dst);
+
+  LLVM_DEBUG(dbgs() << "    common nesting levels = " << CommonLevels << "\n");
+  LLVM_DEBUG(dbgs() << "    maximum nesting levels = " << MaxLevels << "\n");
+  LLVM_DEBUG(dbgs() << "    fusable nesting levels = " << FusableLevels
+                    << "\n");
+
+  // Modify common levels to consider the fusable levels in the tests
+  CommonLevels += FusableLevels;
+  MaxLevels -= FusableLevels;
+  if (FusableLevels > 0) {
+    // Not all tests are handled yet over fusable loops
+    // Revoke if there are any tests other than ZIV, SIV or RDIV
+    for (unsigned P = 0; P < Pairs; ++P) {
+      SmallBitVector Loops;
+      Subscript::ClassificationKind TestClass =
+          classifyPair(Pair[P].Src, LI->getLoopFor(Src->getParent()),
+                       Pair[P].Dst, LI->getLoopFor(Dst->getParent()), Loops);
+
+      if (TestClass != Subscript::ZIV && TestClass != Subscript::SIV &&
+          TestClass != Subscript::RDIV) {
+        // Revert the levels to not consider the fusable levels
+        CommonLevels -= FusableLevels;
+        MaxLevels += FusableLevels;
+        FusableLevels = 0;
+        break;
+      }
+    }
+  }
----------------
amehsan wrote:
you don't need to increment commonLevels and then decrement it. Can you write the code so that it is only incremented when it should be?
https://github.com/llvm/llvm-project/pull/128782
    
    
More information about the llvm-commits
mailing list