[Mlir-commits] [mlir] [mlir][Transforms][NFC] GreedyPatternRewriteDriver: Remove redundant worklist management code (PR #74796)

Matthias Springer llvmlistbot at llvm.org
Thu Dec 7 18:20:21 PST 2023


https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/74796

Do not add the previous users of replaced ops to the worklist during `notifyOperationReplaced`.

The previous users are modified inplace as part of `PatternRewriter::replaceOp`, which calls `PatternRewriter::replaceAllUsesWith`. The latter function updates all users with `updateRootInPlace`, which already puts all previous users of the replaced op on the worklist. No further worklist management work is needed in the `notifyOperationReplaced` callback.

>From 8e470e4a21d2e0968a704f6b02caba463b35b3d0 Mon Sep 17 00:00:00 2001
From: Matthias Springer <springerm at google.com>
Date: Fri, 8 Dec 2023 11:18:48 +0900
Subject: [PATCH] [mlir][Transforms][NFC] GreedyPatternRewriteDriver: Remove
 redundant worklist management code

Do not add the previous users of replaced ops to the worklist during `notifyOperationReplaced`.

The previous users are modified inplace as part of `PatternRewriter::replaceOp`, which calls `PatternRewriter::replaceAllUsesWith`. The latter function updates all users with `updateRootInPlace`, which already puts all previous users of the replaced op on the worklist. No further worklist management work is needed in the `notifyOperationReplaced` callback.
---
 mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
index 8e2bfe557c555..7decbce018a87 100644
--- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
+++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
@@ -581,9 +581,6 @@ void GreedyPatternRewriteDriver::notifyOperationReplaced(
   });
   if (config.listener)
     config.listener->notifyOperationReplaced(op, replacement);
-  for (auto result : op->getResults())
-    for (auto *user : result.getUsers())
-      addToWorklist(user);
 }
 
 LogicalResult GreedyPatternRewriteDriver::notifyMatchFailure(



More information about the Mlir-commits mailing list