[llvm] [SPIRV] Avoid repeated map lookups (NFC) (PR #128129)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 20 21:10:19 PST 2025


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

None

>From ffebc27365e692e62552cb87bd98f884dc8870ee Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 20 Feb 2025 09:32:50 -0800
Subject: [PATCH] [SPIRV] Avoid repeated map lookups (NFC)

---
 llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
index e6b8a381b7180..c7f846b8e9bcc 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
@@ -176,8 +176,9 @@ struct ModuleAnalysisInfo {
     RegisterAliasTable[MF][Reg] = AliasReg;
   }
   Register getRegisterAlias(const MachineFunction *MF, Register Reg) {
-    auto RI = RegisterAliasTable[MF].find(Reg);
-    if (RI == RegisterAliasTable[MF].end()) {
+    auto &RegTable = RegisterAliasTable[MF];
+    auto RI = RegTable.find(Reg);
+    if (RI == RegTable.end()) {
       return Register(0);
     }
     return RI->second;



More information about the llvm-commits mailing list