From 2bbb394a9820aea28258de974acfafec4a9741a9 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 2 Mar 2025 01:10:18 -0800 Subject: [CodeGen] Avoid repeated hash lookups (NFC) (#129418) --- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp') diff --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp index 8d91e71..d6ee019 100644 --- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp +++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp @@ -2054,17 +2054,17 @@ bool AssignmentTrackingLowering::join( // Exactly one visited pred. Copy the LiveOut from that pred into BB LiveIn. if (VisitedPreds.size() == 1) { const BlockInfo &PredLiveOut = LiveOut.find(VisitedPreds[0])->second; - auto CurrentLiveInEntry = LiveIn.find(&BB); // Check if there isn't an entry, or there is but the LiveIn set has // changed (expensive check). - if (CurrentLiveInEntry == LiveIn.end()) - LiveIn.insert(std::make_pair(&BB, PredLiveOut)); - else if (PredLiveOut != CurrentLiveInEntry->second) + auto [CurrentLiveInEntry, Inserted] = LiveIn.try_emplace(&BB, PredLiveOut); + if (Inserted) + return /*Changed*/ true; + if (PredLiveOut != CurrentLiveInEntry->second) { CurrentLiveInEntry->second = PredLiveOut; - else - return /*Changed*/ false; - return /*Changed*/ true; + return /*Changed*/ true; + } + return /*Changed*/ false; } // More than one pred. Join LiveOuts of blocks 1 and 2. -- cgit v1.1