[llvm] cf3aa06 - [Utils] Avoid repeated hash lookups (NFC) (#130464)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 9 00:48:40 PST 2025


Author: Kazu Hirata
Date: 2025-03-09T00:48:37-08:00
New Revision: cf3aa06c1627a6e6606b729fac344fefaeb0ba85

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

LOG: [Utils] Avoid repeated hash lookups (NFC) (#130464)

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index eb03689f31949..833dc7331aecd 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6883,9 +6883,10 @@ static bool switchToLookupTable(SwitchInst *SI, IRBuilder<> &Builder,
     for (const auto &I : Results) {
       PHINode *PHI = I.first;
       Constant *Value = I.second;
-      if (!ResultLists.count(PHI))
+      auto [It, Inserted] = ResultLists.try_emplace(PHI);
+      if (Inserted)
         PHIs.push_back(PHI);
-      ResultLists[PHI].push_back(std::make_pair(CaseVal, Value));
+      It->second.push_back(std::make_pair(CaseVal, Value));
     }
   }
 


        


More information about the llvm-commits mailing list