[llvm] 508db53 - [AMDGPU] Avoid repeated hash lookups (NFC) (#131493)

via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 15 22:35:46 PDT 2025


Author: Kazu Hirata
Date: 2025-03-15T22:35:42-07:00
New Revision: 508db53d1af5b01f8f8275229f087bb6407f0033

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

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

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
index 296031e4a068f..cdd6cb8fdd6fc 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp
@@ -226,9 +226,9 @@ void AMDGPUPALMetadata::setRegister(unsigned Reg, const MCExpr *Val,
       return;
   }
   auto &N = getRegisters()[MsgPackDoc.getNode(Reg)];
-  auto ExprIt = REM.find(Reg);
+  auto [ExprIt, Inserted] = REM.try_emplace(Reg);
 
-  if (ExprIt != REM.end()) {
+  if (!Inserted) {
     Val = MCBinaryExpr::createOr(Val, ExprIt->getSecond(), Ctx);
     // This conditional may be redundant most of the time, but the alternate
     // setRegister(unsigned, unsigned) could've been called while the
@@ -245,7 +245,7 @@ void AMDGPUPALMetadata::setRegister(unsigned Reg, const MCExpr *Val,
     // propagate ORs.
     N = (uint64_t)0;
   }
-  REM[Reg] = Val;
+  ExprIt->second = Val;
   DelayedExprs.assignDocNode(N, msgpack::Type::UInt, Val);
 }
 


        


More information about the llvm-commits mailing list