[Mlir-commits] [mlir] [PDL] Avoid repeated hash lookups (NFC) (PR #108927)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Sep 16 21:28:29 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/108927.diff


1 Files Affected:

- (modified) mlir/lib/Dialect/PDL/IR/PDL.cpp (+2-5) 


``````````diff
diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp
index 428b19f4c74af8..9d7c36520874d3 100644
--- a/mlir/lib/Dialect/PDL/IR/PDL.cpp
+++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp
@@ -65,13 +65,10 @@ static void visit(Operation *op, DenseSet<Operation *> &visited) {
   if (!isa<PatternOp>(op->getParentOp()) || isa<RewriteOp>(op))
     return;
 
-  // Ignore if already visited.
-  if (visited.contains(op))
+  // Ignore if already visited.  Otherwise, mark as visited.
+  if (!visited.insert(op).second)
     return;
 
-  // Mark as visited.
-  visited.insert(op);
-
   // Traverse the operands / parent.
   TypeSwitch<Operation *>(op)
       .Case<OperationOp>([&visited](auto operation) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/108927


More information about the Mlir-commits mailing list