[llvm] [LoopFusion] Perform cheaper dependency check first (NFCI) (PR #228718)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 3 10:23:29 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Ehsan Amiri (amehsan)
<details>
<summary>Changes</summary>
If two stores write the same SSA value to memory, we can skip DA checks. This change of order has a significant impact on compile time of SingleSource/Benchmarks/Misc/himenobmtxpa.c in test suite when fusion runs with no cost model.
Assisted by Claude Code.
---
Full diff: https://github.com/llvm/llvm-project/pull/228718.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Scalar/LoopFuse.cpp (+3-3)
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index 20b05ce6a1302..c819ea49246d3 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -1193,9 +1193,6 @@ struct LoopFuser {
LLVM_DEBUG(dbgs() << "Check dep: " << I0 << " vs " << I1 << "\n");
}
#endif
- auto DepResult = DI.depends(&I0, &I1);
- if (!DepResult)
- return true;
// If two stores write the same SSA value, fusion is safe regardless of
// aliasing - writing the same value twice is idempotent.
if (isa<StoreInst>(I0) && isa<StoreInst>(I1)) {
@@ -1204,6 +1201,9 @@ struct LoopFuser {
if (S0->getValueOperand() == S1->getValueOperand())
return true;
}
+ auto DepResult = DI.depends(&I0, &I1);
+ if (!DepResult)
+ return true;
#ifndef NDEBUG
if (VerboseFusionDebugging) {
LLVM_DEBUG(dbgs() << "DA res: "; DepResult->dump(dbgs());
``````````
</details>
https://github.com/llvm/llvm-project/pull/228718
More information about the llvm-commits
mailing list