[llvm] [GlobalISel] Avoid repeated hash lookups (NFC) (PR #124393)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 19:50:30 PST 2025


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

None

>From 67185000df23601430e85d76af3c1a3e81a5296f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 24 Jan 2025 09:14:18 -0800
Subject: [PATCH] [GlobalISel] Avoid repeated hash lookups (NFC)

---
 llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp b/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
index 3a9069848ca1db..0222069cfc576d 100644
--- a/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
@@ -181,10 +181,7 @@ MachineInstr *GISelCSEInfo::getMachineInstrIfExists(FoldingSetNodeID &ID,
 
 void GISelCSEInfo::countOpcodeHit(unsigned Opc) {
 #ifndef NDEBUG
-  if (OpcodeHitTable.count(Opc))
-    OpcodeHitTable[Opc] += 1;
-  else
-    OpcodeHitTable[Opc] = 1;
+  ++OpcodeHitTable[Opc];
 #endif
   // Else do nothing.
 }



More information about the llvm-commits mailing list