[llvm] [CodeGen] Avoid repeated hash lookups (NFC) (PR #123557)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 19 23:54:03 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-regalloc
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/123557.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/MachineCopyPropagation.cpp (+4-4)
``````````diff
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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/123557
More information about the llvm-commits
mailing list