Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

This patch just cleans up the "if" condition. Further cleanups are
left to subsequent patches.

This patch just cleans up the "if" condition.  Further cleanups are
left to subsequent patches.
@llvmbot
Copy link
Member

llvmbot commented Feb 9, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Kazu Hirata (kazutakahirata)

Changes

This patch just cleans up the "if" condition. Further cleanups are
left to subsequent patches.


Full diff: https://github.com/llvm/llvm-project/pull/126401.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp (+3-3)
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

@kazutakahirata kazutakahirata merged commit 66c31f5 into llvm:main Feb 9, 2025
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_AMDGPU branch February 9, 2025 07:17
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
This patch just cleans up the "if" condition.  Further cleanups are
left to subsequent patches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants