[llvm] [HipStdPar] Avoid repeated hash lookups (NFC) (PR #112653)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 20:33:00 PDT 2024


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

None

>From 50a2e9fc44944bc5f6592f88e3a4feba77326447 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 16 Oct 2024 06:50:33 -0700
Subject: [PATCH] [HipStdPar] Avoid repeated hash lookups (NFC)

---
 llvm/lib/Transforms/HipStdPar/HipStdPar.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/HipStdPar/HipStdPar.cpp b/llvm/lib/Transforms/HipStdPar/HipStdPar.cpp
index d740500ef1f8f6..b909bf5b2d7b61 100644
--- a/llvm/lib/Transforms/HipStdPar/HipStdPar.cpp
+++ b/llvm/lib/Transforms/HipStdPar/HipStdPar.cpp
@@ -86,15 +86,13 @@ static inline bool checkIfSupported(GlobalVariable &G) {
     auto U = std::move(Tmp.back());
     Tmp.pop_back();
 
-    if (Visited.contains(U))
+    if (!Visited.insert(U).second)
       continue;
 
     if (isa<Instruction>(U))
       I = cast<Instruction>(U);
     else
       Tmp.insert(Tmp.end(), U->user_begin(), U->user_end());
-
-    Visited.insert(U);
   } while (!I && !Tmp.empty());
 
   assert(I && "thread_local global should have at least one non-constant use.");



More information about the llvm-commits mailing list