[llvm] 2bbb394 - [CodeGen] Avoid repeated hash lookups (NFC) (#129418)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 2 01:10:21 PST 2025


Author: Kazu Hirata
Date: 2025-03-02T01:10:18-08:00
New Revision: 2bbb394a9820aea28258de974acfafec4a9741a9

URL: https://github.com/llvm/llvm-project/commit/2bbb394a9820aea28258de974acfafec4a9741a9
DIFF: https://github.com/llvm/llvm-project/commit/2bbb394a9820aea28258de974acfafec4a9741a9.diff

LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#129418)

Added: 
    

Modified: 
    llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
index 8d91e7119d0ba..d6ee019383bc8 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.


        


More information about the llvm-commits mailing list