[llvm] [AMDGPU] Avoid repeated hash lookups (NFC) (PR #131493)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 15 21:24:06 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/131493
None
>From 5cd713f75314a01db3625204d59b537ac0e0d7ba Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 15 Mar 2025 09:16:36 -0700
Subject: [PATCH] [AMDGPU] Avoid repeated hash lookups (NFC)
---
llvm/lib/Target/AMDGPU/Utils/AMDGPUPALMetadata.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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