summaryrefslogtreecommitdiff
path: root/mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp
diff options
context:
space:
mode:
authorMatthias Springer <me@m-sp.org>2024-01-25 11:01:28 +0100
committerGitHub <noreply@github.com>2024-01-25 11:01:28 +0100
commit5cc0f76d34c7d00fa3e4ff01efe24d5de592e82c (patch)
tree04291163fb3678c3cd546d04045efe8d69591c7b /mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp
parent45fec0c110cccd5e0c9b60d51bc2ffc1645c9a40 (diff)
[mlir][IR] Add rewriter API for moving operations (#78988)
The pattern rewriter documentation states that "*all* IR mutations [...] are required to be performed via the `PatternRewriter`." This commit adds two functions that were missing from the rewriter API: `moveOpBefore` and `moveOpAfter`. After an operation was moved, the `notifyOperationInserted` callback is triggered. This allows listeners such as the greedy pattern rewrite driver to react to IR changes. This commit narrows the discrepancy between the kind of IR modification that can be performed and the kind of IR modifications that can be listened to.
Diffstat (limited to 'mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp')
-rw-r--r--mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp b/mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp
index 8f97fd3d9ddf..66ce6067963f 100644
--- a/mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopInvariantCodeMotionUtils.cpp
@@ -365,8 +365,8 @@ static LoopLikeOpInterface hoistSubsetAtIterArg(RewriterBase &rewriter,
iterArg = loopLike.getRegionIterArgs()[iterArgIdx];
OpResult loopResult = loopLike.getTiedLoopResult(iterArg);
OpResult newLoopResult = loopLike.getLoopResults()->back();
- extractionOp->moveBefore(loopLike);
- insertionOp->moveAfter(loopLike);
+ rewriter.moveOpBefore(extractionOp, loopLike);
+ rewriter.moveOpAfter(insertionOp, loopLike);
rewriter.replaceAllUsesWith(insertionOp.getUpdatedDestination(),
insertionOp.getDestinationOperand().get());
extractionOp.getSourceOperand().set(