From 1a4341d7369c8b69650e150e0327105af1375089 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Wed, 15 Jan 2025 09:12:10 -0800 Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC) --- llvm/lib/CodeGen/MachineCSE.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp index 0a547050e91a8..728fd2f5f7cd4 100644 --- a/llvm/lib/CodeGen/MachineCSE.cpp +++ b/llvm/lib/CodeGen/MachineCSE.cpp @@ -832,12 +832,11 @@ bool MachineCSEImpl::ProcessBlockPRE(MachineDominatorTree *DT, if (!isPRECandidate(&MI, PhysRefs)) continue; - if (!PREMap.count(&MI)) { - PREMap[&MI] = MBB; + auto [It, Inserted] = PREMap.try_emplace(&MI, MBB); + if (Inserted) continue; - } - auto MBB1 = PREMap[&MI]; + auto *MBB1 = It->second; assert( !DT->properlyDominates(MBB, MBB1) && "MBB cannot properly dominate MBB1 while DFS through dominators tree!");