[llvm] [AMDGPU] Avoid repeated hash lookups (NFC) (PR #132511)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 21 20:52:19 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/132511
None
>From 12fd6144897e324ff33b1ce1aea9a6fa9dc36f3c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 21 Mar 2025 08:28:10 -0700
Subject: [PATCH] [AMDGPU] Avoid repeated hash lookups (NFC)
---
llvm/lib/Target/AMDGPU/GCNRegPressure.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
index a438ad00bc41d..f74d12cfab0c0 100644
--- a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
@@ -692,8 +692,8 @@ GCNDownwardRPTracker::bumpDownwardPressure(const MachineInstr *MI,
if (LastUseMask.none())
continue;
- LaneBitmask LiveMask =
- LiveRegs.contains(Reg) ? LiveRegs.at(Reg) : LaneBitmask(0);
+ auto It = LiveRegs.find(Reg);
+ LaneBitmask LiveMask = It != LiveRegs.end() ? It->second : LaneBitmask(0);
LaneBitmask NewMask = LiveMask & ~LastUseMask;
TempPressure.inc(Reg, LiveMask, NewMask, *MRI);
}
@@ -703,8 +703,8 @@ GCNDownwardRPTracker::bumpDownwardPressure(const MachineInstr *MI,
Register Reg = Def.RegUnit;
if (!Reg.isVirtual())
continue;
- LaneBitmask LiveMask =
- LiveRegs.contains(Reg) ? LiveRegs.at(Reg) : LaneBitmask(0);
+ auto It = LiveRegs.find(Reg);
+ LaneBitmask LiveMask = It != LiveRegs.end() ? It->second : LaneBitmask(0);
LaneBitmask NewMask = LiveMask | Def.LaneMask;
TempPressure.inc(Reg, LiveMask, NewMask, *MRI);
}
More information about the llvm-commits
mailing list