[llvm] [LoopFusion] Extending SIV to handle separate loops (PR #146383)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 23 21:59:58 PDT 2025
================
@@ -1371,6 +1373,33 @@ struct LoopFuser {
<< "\n");
}
#endif
+ unsigned Levels = DepResult->getLevels();
+ unsigned SameSDLevels = DepResult->getSameSDLevels();
+ unsigned CurLoopLevel = FC0.L->getLoopDepth();
+
+ bool OuterEqDir = true;
+ for (unsigned II = 1; II <= std::min(CurLoopLevel - 1, Levels); ++II) {
+ unsigned Direction = DepResult->getDirection(II, II > Levels);
+ if (!(Direction & Dependence::DVEntry::EQ)) {
+ // Different accesses in the outer levels of CurLoopLevel
+ OuterEqDir = false;
+ break;
+ }
+ }
+ if (!OuterEqDir || CurLoopLevel > Levels + SameSDLevels) {
+ LLVM_DEBUG(dbgs() << "Safe to fuse with no dependency\n");
+ NumDepSafeFused++;
+ return true;
+ }
+
+ assert(CurLoopLevel > Levels && "Fusion candidates are not separated");
+ unsigned CurDir = DepResult->getDirection(CurLoopLevel, true);
+ if (!(CurDir & Dependence::DVEntry::GT)) {
----------------
CongzheUalberta wrote:
Would it be more readable if it is changed to the following?
```if (CurDir != Dependence::DVEntry::GT)```
https://github.com/llvm/llvm-project/pull/146383
More information about the llvm-commits
mailing list