[llvm] [LoopFusion][NFC] Avoid copying fusion candidates per pair (PR #203461)
Madhur Amilkanthwar via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 22:46:16 PDT 2026
https://github.com/madhur13490 created https://github.com/llvm/llvm-project/pull/203461
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.
>From d659c6cebbd6df51ec87955065ce809a266a703e Mon Sep 17 00:00:00 2001
From: Madhur Amilkanthwar <madhura at nvidia.com>
Date: Fri, 5 Jun 2026 02:00:01 -0700
Subject: [PATCH] [LoopFusion] Avoid copying fusion candidates per pair (NFC)
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.
---
llvm/lib/Transforms/Scalar/LoopFuse.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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!");
More information about the llvm-commits
mailing list