aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineCopyPropagation.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-01-20 10:13:08 -0800
committerGitHub <noreply@github.com>2025-01-20 10:13:08 -0800
commitbc1e699d9fb52548c1bc2420f10929473a4c3908 (patch)
tree323d38da2f083b70556c0bdd2cb7be111813e62f /llvm/lib/CodeGen/MachineCopyPropagation.cpp
parentcac3f5ecb972194322aeeb8e84e7c7dd60dedef8 (diff)
downloadllvm-bc1e699d9fb52548c1bc2420f10929473a4c3908.zip
llvm-bc1e699d9fb52548c1bc2420f10929473a4c3908.tar.gz
llvm-bc1e699d9fb52548c1bc2420f10929473a4c3908.tar.bz2
[CodeGen] Avoid repeated hash lookups (NFC) (#123557)
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineCopyPropagation.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index 0afd73d..d44b064 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -127,11 +127,11 @@ public:
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)