[llvm] [LoopFusion] Extending SIV to handle separate loops (PR #146383)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 18 15:58:10 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/Analysis/DependenceAnalysis.h llvm/lib/Analysis/DependenceAnalysis.cpp llvm/lib/Transforms/Scalar/LoopFuse.cpp
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Analysis/DependenceAnalysis.h b/llvm/include/llvm/Analysis/DependenceAnalysis.h
index 744e7c01a..aaf990db3 100644
--- a/llvm/include/llvm/Analysis/DependenceAnalysis.h
+++ b/llvm/include/llvm/Analysis/DependenceAnalysis.h
@@ -83,7 +83,7 @@ public:
   /// has a direction (or perhaps a union of several directions), and
   /// perhaps a distance.
   /// The dependency information could be across a single loop level or across
-  /// two separate levels that have the same trip count and nesting depth, 
+  /// two separate levels that have the same trip count and nesting depth,
   /// which helps to provide information for loop fusion candidation.
   /// For example, loops b and c have the same iteration count and depth:
   ///    for (a = ...) {
@@ -602,7 +602,7 @@ private:
   /// SIDStrictLevels counts the number of levels after common levels that are
   /// not common but have the same iteration count and depth. Internally this
   /// is checked using isSID. Assume that in this code fragment, levels c and e
-  /// have the same iteration count and depth, but levels d and f does not. 
+  /// have the same iteration count and depth, but levels d and f does not.
   /// Then SIDStrictLevels is set to 1.
   /// In that case the level numbers for the previous code look like
   ///     a   - 1
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp
index 5d50e8cce..1d9a318e5 100644
--- a/llvm/lib/Analysis/DependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/DependenceAnalysis.cpp
@@ -389,7 +389,8 @@ bool FullDependence::isSplitable(unsigned Level, bool SID) const {
 // performed across two separate loop nests that have the Same Iteration and
 // Depth.
 bool FullDependence::inSIDLoops(unsigned Level) const {
-  assert(0 < Level && Level <= Levels + SIDStrictLevels && "Level out of range");
+  assert(0 < Level && Level <= Levels + SIDStrictLevels &&
+         "Level out of range");
   return Level > Levels;
 }
 
@@ -800,8 +801,7 @@ static bool isLoadOrStore(const Instruction *I) {
 }
 
 // Returns true if two loops have Same Iteration and Depth.
-bool DependenceInfo::isSID(const Loop *SrcLoop,
-                                        const Loop *DstLoop) const {
+bool DependenceInfo::isSID(const Loop *SrcLoop, const Loop *DstLoop) const {
   if (SrcLoop == DstLoop)
     return true;
 
@@ -818,7 +818,7 @@ bool DependenceInfo::isSID(const Loop *SrcLoop,
   if (SE->hasLoopInvariantBackedgeTakenCount(DstLoop))
     DstUP = SE->getBackedgeTakenCount(DstLoop);
 
-  if (SrcUB != nullptr && DstUP != nullptr && 
+  if (SrcUB != nullptr && DstUP != nullptr &&
       SE->isKnownPredicate(ICmpInst::ICMP_EQ, SrcUB, DstUP))
     return true;
 
@@ -878,7 +878,7 @@ bool DependenceInfo::isSID(const Loop *SrcLoop,
 // SIDStrictLevels counts the number of levels after common levels that are
 // not common but have the same iteration count and depth. Internally this
 // is checked using isSID. Assume that in this code fragment, levels c and e
-// have the same iteration count and depth, but levels d and f does not. 
+// have the same iteration count and depth, but levels d and f does not.
 // Then SIDStrictLevels is set to 1.
 // In that case the level numbers for the previous code look like
 //     a   - 1
@@ -3811,8 +3811,7 @@ DependenceInfo::depends(Instruction *Src, Instruction *Dst,
 
   LLVM_DEBUG(dbgs() << "    common nesting levels = " << CommonLevels << "\n");
   LLVM_DEBUG(dbgs() << "    maximum nesting levels = " << MaxLevels << "\n");
-  LLVM_DEBUG(dbgs() << "    SID nesting levels = " << SIDStrictLevels
-                    << "\n");
+  LLVM_DEBUG(dbgs() << "    SID nesting levels = " << SIDStrictLevels << "\n");
 
   // Modify common levels to consider the SID levels in the tests
   CommonLevels += SIDStrictLevels;

``````````

</details>


https://github.com/llvm/llvm-project/pull/146383


More information about the llvm-commits mailing list