[llvm] bc1e699 - [CodeGen] Avoid repeated hash lookups (NFC) (#123557)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 10:13:11 PST 2025
Author: Kazu Hirata
Date: 2025-01-20T10:13:08-08:00
New Revision: bc1e699d9fb52548c1bc2420f10929473a4c3908
URL: https://github.com/llvm/llvm-project/commit/bc1e699d9fb52548c1bc2420f10929473a4c3908
DIFF: https://github.com/llvm/llvm-project/commit/bc1e699d9fb52548c1bc2420f10929473a4c3908.diff
LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#123557)
Added:
Modified:
llvm/lib/CodeGen/MachineCopyPropagation.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index 0afd73d8ecdccb..d44b064dcb4b2e 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -127,11 +127,11 @@ class CopyTracker {
BitVector &getPreservedRegUnits(const MachineOperand &RegMaskOp,
const TargetRegisterInfo &TRI) {
const uint32_t *RegMask = RegMaskOp.getRegMask();
- auto Existing = RegMaskToPreservedRegUnits.find(RegMask);
- if (Existing != RegMaskToPreservedRegUnits.end()) {
- return Existing->second;
+ auto [It, Inserted] = RegMaskToPreservedRegUnits.try_emplace(RegMask);
+ if (!Inserted) {
+ return It->second;
} else {
- BitVector &PreservedRegUnits = RegMaskToPreservedRegUnits[RegMask];
+ BitVector &PreservedRegUnits = It->second;
PreservedRegUnits.resize(TRI.getNumRegUnits());
for (unsigned SafeReg = 0, E = TRI.getNumRegs(); SafeReg < E; ++SafeReg)
More information about the llvm-commits
mailing list