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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Sep 17 00:18:52 PDT 2024


Author: Kazu Hirata
Date: 2024-09-17T00:18:49-07:00
New Revision: 9825d1ffcdee409864dc499394b1c2d2247822f0

URL: https://github.com/llvm/llvm-project/commit/9825d1ffcdee409864dc499394b1c2d2247822f0
DIFF: https://github.com/llvm/llvm-project/commit/9825d1ffcdee409864dc499394b1c2d2247822f0.diff

LOG: [PDL] Avoid repeated hash lookups (NFC) (#108927)

Added: 
    

Modified: 
    mlir/lib/Dialect/PDL/IR/PDL.cpp

Removed: 
    


################################################################################
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) {


        


More information about the Mlir-commits mailing list