[Mlir-commits] [mlir] [Transforms] Avoid repeated hash lookups (NFC) (PR #108322)

Kazu Hirata llvmlistbot at llvm.org
Wed Sep 11 20:01:04 PDT 2024


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

None

>From 48be3231942e7d01b0876c5c8cf01e731e71a29a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 11 Sep 2024 06:44:30 -0700
Subject: [PATCH] [Transforms] Avoid repeated hash lookups (NFC)

---
 mlir/lib/Transforms/Mem2Reg.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mlir/lib/Transforms/Mem2Reg.cpp b/mlir/lib/Transforms/Mem2Reg.cpp
index 4bc2bbd12b0945..144f9f01142a09 100644
--- a/mlir/lib/Transforms/Mem2Reg.cpp
+++ b/mlir/lib/Transforms/Mem2Reg.cpp
@@ -343,9 +343,8 @@ SmallPtrSet<Block *, 16> MemorySlotPromotionAnalyzer::computeSlotLiveIn(
   // blocks.
   SmallPtrSet<Block *, 16> visited;
   for (Operation *user : slot.ptr.getUsers()) {
-    if (visited.contains(user->getBlock()))
+    if (!visited.insert(user->getBlock()).second)
       continue;
-    visited.insert(user->getBlock());
 
     for (Operation &op : user->getBlock()->getOperations()) {
       if (auto memOp = dyn_cast<PromotableMemOpInterface>(op)) {



More information about the Mlir-commits mailing list