[llvm] [LoopFusion][NFC] Avoid copying fusion candidates per pair (PR #203461)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 22:46:56 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Madhur Amilkanthwar (madhur13490)
<details>
<summary>Changes</summary>
`fuseCandidates()` copied both candidates (each holding two `SmallVector<Instruction *, 16>`) for every adjacent pair examined, even pairs rejected by an early continue. Bind them by const reference; they are only read before being erased from the list, and performFusion runs before the erases.
---
Full diff: https://github.com/llvm/llvm-project/pull/203461.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Scalar/LoopFuse.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index b5126f9f3b704..1b83c971c01bf 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -746,8 +746,8 @@ struct LoopFuser {
for (auto It = CandidateList.begin(), NextIt = std::next(It);
NextIt != CandidateList.end(); It = NextIt, NextIt = std::next(It)) {
- auto FC0 = *It;
- auto FC1 = *NextIt;
+ const FusionCandidate &FC0 = *It;
+ const FusionCandidate &FC1 = *NextIt;
assert(!LDT.isRemovedLoop(FC0.L) &&
"Should not have removed loops in CandidateList!");
``````````
</details>
https://github.com/llvm/llvm-project/pull/203461
More information about the llvm-commits
mailing list