[llvm] 66c31f5 - [AMDGPU] Avoid repeated hash lookups (NFC) (#126401)

via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 8 23:17:09 PST 2025


Author: Kazu Hirata
Date: 2025-02-08T23:17:06-08:00
New Revision: 66c31f5d024f3ec9f9afa74c340ba0a4e0776823

URL: https://github.com/llvm/llvm-project/commit/66c31f5d024f3ec9f9afa74c340ba0a4e0776823
DIFF: https://github.com/llvm/llvm-project/commit/66c31f5d024f3ec9f9afa74c340ba0a4e0776823.diff

LOG: [AMDGPU] Avoid repeated hash lookups (NFC) (#126401)

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

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp

Removed: 
    


################################################################################
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