[llvm] [Transforms] Avoid repeated hash lookups (NFC) (PR #125350)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 1 09:19:08 PST 2025


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

None

>From 618c003d4bd8e8f7c1f3e1744b863b0024b51d66 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 31 Jan 2025 21:58:04 -0800
Subject: [PATCH] [Transforms] Avoid repeated hash lookups (NFC)

---
 llvm/lib/Transforms/Scalar/NewGVN.cpp | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index d8b0bd173454f4a..168f1d689d3149f 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -3056,13 +3056,8 @@ std::pair<unsigned, unsigned> NewGVN::assignDFSNumbers(BasicBlock *B,
 
 void NewGVN::updateProcessedCount(const Value *V) {
 #ifndef NDEBUG
-  if (ProcessedCount.count(V) == 0) {
-    ProcessedCount.insert({V, 1});
-  } else {
-    ++ProcessedCount[V];
-    assert(ProcessedCount[V] < 100 &&
-           "Seem to have processed the same Value a lot");
-  }
+  assert(++ProcessedCount[V] < 100 &&
+         "Seem to have processed the same Value a lot");
 #endif
 }
 



More information about the llvm-commits mailing list