Skip to content

Commit 508db53

Browse files
[AMDGPU] Avoid repeated hash lookups (NFC) (#131493)
1 parent d017767 commit 508db53

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ void AMDGPUPALMetadata::setRegister(unsigned Reg, const MCExpr *Val,
226226
return;
227227
}
228228
auto &N = getRegisters()[MsgPackDoc.getNode(Reg)];
229-
auto ExprIt = REM.find(Reg);
229+
auto [ExprIt, Inserted] = REM.try_emplace(Reg);
230230

231-
if (ExprIt != REM.end()) {
231+
if (!Inserted) {
232232
Val = MCBinaryExpr::createOr(Val, ExprIt->getSecond(), Ctx);
233233
// This conditional may be redundant most of the time, but the alternate
234234
// setRegister(unsigned, unsigned) could've been called while the
@@ -245,7 +245,7 @@ void AMDGPUPALMetadata::setRegister(unsigned Reg, const MCExpr *Val,
245245
// propagate ORs.
246246
N = (uint64_t)0;
247247
}
248-
REM[Reg] = Val;
248+
ExprIt->second = Val;
249249
DelayedExprs.assignDocNode(N, msgpack::Type::UInt, Val);
250250
}
251251

0 commit comments

Comments
 (0)