From d1cba23d2ec4b8ea65b15052b1c9f3553f62b992 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 19 Jan 2025 12:07:23 -0800 Subject: [PATCH] [InstCombine] Avoid repeated hash lookups (NFC) --- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp index 842881156dc67..a2730396a0ea2 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -4179,13 +4179,14 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) { DenseMap Val2Idx; std::vector 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()) {