[llvm] 7fa1936 - [InstCombine] Avoid repeated hash lookups (NFC) (#123559)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 20 10:14:21 PST 2025


Author: Kazu Hirata
Date: 2025-01-20T10:14:18-08:00
New Revision: 7fa1936947194ec7425d5d21ce43d69d5b09dd2d

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

LOG: [InstCombine] Avoid repeated hash lookups (NFC) (#123559)

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index b1797360a7bfc9..e2b81ba864c3c7 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -4206,13 +4206,14 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
     DenseMap<Value *, unsigned> Val2Idx;
     std::vector<Value *> NewLiveGc;
     for (Value *V : Bundle->Inputs) {
-      if (Val2Idx.count(V))
+      auto [It, Inserted] = Val2Idx.try_emplace(V);
+      if (!Inserted)
         continue;
       if (LiveGcValues.count(V)) {
-        Val2Idx[V] = NewLiveGc.size();
+        It->second = NewLiveGc.size();
         NewLiveGc.push_back(V);
       } else
-        Val2Idx[V] = NumOfGCLives;
+        It->second = NumOfGCLives;
     }
     // Update all gc.relocates
     for (const GCRelocateInst *Reloc : GCSP.getGCRelocates()) {


        


More information about the llvm-commits mailing list