[llvm] [AMDGPU] Avoid repeated hash lookups (NFC) (PR #113409)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 20:05:30 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/113409

None

>From 2f7416231e368df40a93558f061df7961a895354 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 22 Oct 2024 08:12:10 -0700
Subject: [PATCH] [AMDGPU] Avoid repeated hash lookups (NFC)

---
 llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
index 77350dbb6167cb..c80d60c3a52112 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
@@ -329,8 +329,8 @@ bool LiveRegOptimizer::optimizeLiveType(
         Type *NewType = calculateConvertType(Phi->getType());
         NewPhi->addIncoming(ConstantInt::get(NewType, 0, false),
                             Phi->getIncomingBlock(I));
-      } else if (ValMap.contains(IncVal) && ValMap[IncVal])
-        NewPhi->addIncoming(ValMap[IncVal], Phi->getIncomingBlock(I));
+      } else if (Value *Val = ValMap.lookup(IncVal))
+        NewPhi->addIncoming(Val, Phi->getIncomingBlock(I));
       else
         MissingIncVal = true;
     }



More information about the llvm-commits mailing list