[llvm] [AMDGPU] Avoid repeated hash lookups (NFC) (PR #112115)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 12 21:10:50 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/112115
None
>From 9b59696b7f2c9170ebd51fcb07b85cc19cf0a032 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 12 Oct 2024 08:16:31 -0700
Subject: [PATCH] [AMDGPU] Avoid repeated hash lookups (NFC)
---
llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp b/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp
index 0d3a221970bf85..ddfa7790cabc6b 100644
--- a/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFormMemoryClauses.cpp
@@ -227,11 +227,9 @@ void SIFormMemoryClauses::collectRegUses(const MachineInstr &MI,
: LaneBitmask::getAll();
RegUse &Map = MO.isDef() ? Defs : Uses;
- auto Loc = Map.find(Reg);
unsigned State = getMopState(MO);
- if (Loc == Map.end()) {
- Map[Reg] = std::pair(State, Mask);
- } else {
+ auto [Loc, Inserted] = Map.try_emplace(Reg, State, Mask);
+ if (!Inserted) {
Loc->second.first |= State;
Loc->second.second |= Mask;
}
More information about the llvm-commits
mailing list