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

Kazu Hirata llvmlistbot at llvm.org
Tue Sep 10 20:11:23 PDT 2024


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

None

>From af59eb58c603ba994e722f8ba78fb1facb92721f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 10 Sep 2024 07:45:04 -0700
Subject: [PATCH] [Transforms] Avoid repeated hash lookups (NFC)

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

diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index 450e66f0db4e74..f288c7fc2cb77b 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -2486,9 +2486,8 @@ static void eraseDeadUnrealizedCasts(
 
     // Do not visit ops multiple times. If we find a circle, no live user was
     // found on the current path.
-    if (visited.contains(op))
+    if (!visited.insert(op).second)
       return false;
-    visited.insert(op);
 
     // Visit all users.
     for (Operation *user : op->getUsers()) {



More information about the Mlir-commits mailing list