[llvm] 48deb35 - [AMDGPU] Avoid repeated hash lookups (NFC) (#112115)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 12 22:07:25 PDT 2024


Author: Kazu Hirata
Date: 2024-10-12T22:07:22-07:00
New Revision: 48deb3568eb2452ff385b04b8f71c34121f47387

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

LOG: [AMDGPU] Avoid repeated hash lookups (NFC) (#112115)

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp b/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp
index 0d3a221970bf85..ddfa7790cabc6b 100644
--- a/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp
@@ -227,11 +227,9 @@ void SIFormMemoryClauses::collectRegUses(const MachineInstr &MI,
                            : LaneBitmask::getAll();
     RegUse &Map = MO.isDef() ? Defs : Uses;
 
-    auto Loc = Map.find(Reg);
     unsigned State = getMopState(MO);
-    if (Loc == Map.end()) {
-      Map[Reg] = std::pair(State, Mask);
-    } else {
+    auto [Loc, Inserted] = Map.try_emplace(Reg, State, Mask);
+    if (!Inserted) {
       Loc->second.first |= State;
       Loc->second.second |= Mask;
     }


        


More information about the llvm-commits mailing list