[llvm] 06c7de4 - [LoopFusion][NFC] Avoid copying fusion candidates per pair (#203461)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 23:17:36 PDT 2026


Author: Madhur Amilkanthwar
Date: 2026-06-12T06:17:30Z
New Revision: 06c7de45221621a0773d125ff7d016df87eb3d62

URL: https://github.com/llvm/llvm-project/commit/06c7de45221621a0773d125ff7d016df87eb3d62
DIFF: https://github.com/llvm/llvm-project/commit/06c7de45221621a0773d125ff7d016df87eb3d62.diff

LOG: [LoopFusion][NFC] Avoid copying fusion candidates per pair (#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.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopFuse.cpp

Removed: 
    


################################################################################
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