[llvm] [Analysis] Avoid repeated hash lookups (NFC) (PR #109564)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 22:43:57 PDT 2024


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

None

>From 23e9b9f383ba8f96e5a158eafbc8719fe0bf6b9e Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 21 Sep 2024 09:36:51 -0700
Subject: [PATCH] [Analysis] Avoid repeated hash lookups (NFC)

---
 llvm/include/llvm/Analysis/GenericDomTreeUpdaterImpl.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/include/llvm/Analysis/GenericDomTreeUpdaterImpl.h b/llvm/include/llvm/Analysis/GenericDomTreeUpdaterImpl.h
index 35c54a6062bfd4..b79eaef57710fa 100644
--- a/llvm/include/llvm/Analysis/GenericDomTreeUpdaterImpl.h
+++ b/llvm/include/llvm/Analysis/GenericDomTreeUpdaterImpl.h
@@ -107,8 +107,7 @@ void GenericDomTreeUpdater<DerivedT, DomTreeT, PostDomTreeT>::
     // b. If the edge doesn't exist, we can then infer that {Delete, A, B}
     // actually happened but {Insert, A, B} was an invalid update which never
     // happened. DTU will submit {Delete, A, B} in this case.
-    if (!isSelfDominance(U) && Seen.count(Edge) == 0) {
-      Seen.insert(Edge);
+    if (!isSelfDominance(U) && Seen.insert(Edge).second) {
       // If the update doesn't appear in the CFG, it means that
       // either the change isn't made or relevant operations
       // result in a no-op.



More information about the llvm-commits mailing list