[llvm] [AMDGPU] Avoid repeated hash lookups (NFC) (PR #126401)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 8 21:26:19 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/126401
This patch just cleans up the "if" condition. Further cleanups are
left to subsequent patches.
>From b099b32540ffd468cc23eb07c316007117fd8d94 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 8 Feb 2025 11:46:02 -0800
Subject: [PATCH] [AMDGPU] Avoid repeated hash lookups (NFC)
This patch just cleans up the "if" condition. Further cleanups are
left to subsequent patches.
---
llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
index f4e651ec477d30a..b8109db821bcc38 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
@@ -367,11 +367,11 @@ bool LiveRegOptimizer::optimizeLiveType(
for (Instruction *U : Uses) {
// Replace all converted operands for a use.
for (auto [OpIdx, Op] : enumerate(U->operands())) {
- if (ValMap.contains(Op) && ValMap[Op]) {
+ if (Value *Val = ValMap.lookup(Op)) {
Value *NewVal = nullptr;
if (BBUseValMap.contains(U->getParent()) &&
- BBUseValMap[U->getParent()].contains(ValMap[Op]))
- NewVal = BBUseValMap[U->getParent()][ValMap[Op]];
+ BBUseValMap[U->getParent()].contains(Val))
+ NewVal = BBUseValMap[U->getParent()][Val];
else {
BasicBlock::iterator InsertPt = U->getParent()->getFirstNonPHIIt();
// We may pick up ops that were previously converted for users in
More information about the llvm-commits
mailing list