[llvm] 0963f0d - [AMDGPU] Avoid repeated hash lookups (NFC) (#128393)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 22 21:03:26 PST 2025
Author: Kazu Hirata
Date: 2025-02-22T21:03:23-08:00
New Revision: 0963f0d6459c50f3dc7e4628b3b1160fd6c2fa92
URL: https://github.com/llvm/llvm-project/commit/0963f0d6459c50f3dc7e4628b3b1160fd6c2fa92
DIFF: https://github.com/llvm/llvm-project/commit/0963f0d6459c50f3dc7e4628b3b1160fd6c2fa92.diff
LOG: [AMDGPU] Avoid repeated hash lookups (NFC) (#128393)
Added:
Modified:
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index fa15e73bc31d5..641365d319a50 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -1084,13 +1084,11 @@ void SIFoldOperandsImpl::foldOperand(
}
if (CopyToVGPR.Reg) {
- Register Vgpr;
- if (VGPRCopies.count(CopyToVGPR)) {
- Vgpr = VGPRCopies[CopyToVGPR];
- } else {
+ auto [It, Inserted] = VGPRCopies.try_emplace(CopyToVGPR);
+ Register &Vgpr = It->second;
+ if (Inserted) {
Vgpr = MRI->createVirtualRegister(&AMDGPU::VGPR_32RegClass);
BuildMI(MBB, UseMI, DL, TII->get(AMDGPU::COPY), Vgpr).add(*Def);
- VGPRCopies[CopyToVGPR] = Vgpr;
}
auto Tmp = MRI->createVirtualRegister(&AMDGPU::AGPR_32RegClass);
BuildMI(MBB, UseMI, DL,
More information about the llvm-commits
mailing list