[Mlir-commits] [mlir] 2c40a0a - [mlir][IR][NFC] Rename RewriterBase::replaceUseIf to replaceUsesWithIf

Matthias Springer llvmlistbot at llvm.org
Wed Feb 22 07:18:47 PST 2023


Author: Matthias Springer
Date: 2023-02-22T16:13:18+01:00
New Revision: 2c40a0a63ed0c3291698373bf2bdd98b11b1a2c1

URL: https://github.com/llvm/llvm-project/commit/2c40a0a63ed0c3291698373bf2bdd98b11b1a2c1
DIFF: https://github.com/llvm/llvm-project/commit/2c40a0a63ed0c3291698373bf2bdd98b11b1a2c1.diff

LOG: [mlir][IR][NFC] Rename RewriterBase::replaceUseIf to replaceUsesWithIf

This is for consistency with `Value::replaceUsesWithIf`.

Differential Revision: https://reviews.llvm.org/D144547

Added: 
    

Modified: 
    mlir/include/mlir/IR/PatternMatch.h
    mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
    mlir/lib/IR/PatternMatch.cpp
    mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp
    mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index daade923034aa..fce6633bb7105 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -550,14 +550,15 @@ class RewriterBase : public OpBuilder {
   /// Find uses of `from` and replace them with `to` if the `functor` returns
   /// true. It also marks every modified uses and notifies the rewriter that an
   /// in-place operation modification is about to happen.
-  void replaceUseIf(Value from, Value to,
+  void
+  replaceUsesWithIf(Value from, Value to,
                     llvm::unique_function<bool(OpOperand &) const> functor);
 
   /// Find uses of `from` and replace them with `to` except if the user is
   /// `exceptedUser`. It also marks every modified uses and notifies the
   /// rewriter that an in-place operation modification is about to happen.
   void replaceAllUsesExcept(Value from, Value to, Operation *exceptedUser) {
-    return replaceUseIf(from, to, [&](OpOperand &use) {
+    return replaceUsesWithIf(from, to, [&](OpOperand &use) {
       Operation *user = use.getOwner();
       return user != exceptedUser;
     });

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
index a15d657681c5c..d37ceaee35e1e 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp
@@ -428,7 +428,7 @@ class FuseElementwiseOps : public OpRewritePattern<GenericOp> {
         return rewriter.notifyMatchFailure(genericOp, "fusion failed");
       Operation *producer = opOperand.get().getDefiningOp();
       for (auto [origVal, replacement] : fusionResult->replacements) {
-        rewriter.replaceUseIf(origVal, replacement, [&](OpOperand &use) {
+        rewriter.replaceUsesWithIf(origVal, replacement, [&](OpOperand &use) {
           // Only replace consumer uses.
           return use.get().getDefiningOp() != producer;
         });

diff  --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp
index 958d82ae5bcbe..a01ccca5d33ad 100644
--- a/mlir/lib/IR/PatternMatch.cpp
+++ b/mlir/lib/IR/PatternMatch.cpp
@@ -326,7 +326,7 @@ void RewriterBase::mergeBlocks(Block *source, Block *dest,
 /// Find uses of `from` and replace them with `to` if the `functor` returns
 /// true. It also marks every modified uses and notifies the rewriter that an
 /// in-place operation modification is about to happen.
-void RewriterBase::replaceUseIf(
+void RewriterBase::replaceUsesWithIf(
     Value from, Value to,
     llvm::unique_function<bool(OpOperand &) const> functor) {
   for (OpOperand &operand : llvm::make_early_inc_range(from.getUses())) {

diff  --git a/mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp b/mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp
index 1593eaf264221..dbd054e080de9 100644
--- a/mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp
+++ b/mlir/test/lib/Dialect/Linalg/TestLinalgElementwiseFusion.cpp
@@ -74,7 +74,7 @@ struct TestMultiUseProducerFusion : public OpRewritePattern<linalg::GenericOp> {
     if (!fusionResult)
       return rewriter.notifyMatchFailure(genericOp, "fusion failed");
     for (auto [origValue, replacement] : fusionResult->replacements) {
-      rewriter.replaceUseIf(origValue, replacement, [&](OpOperand &use) {
+      rewriter.replaceUsesWithIf(origValue, replacement, [&](OpOperand &use) {
         return use.getOwner() != genericOp.getOperation();
       });
     }

diff  --git a/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp b/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp
index 0fc091368ff1e..c362bcd57722d 100644
--- a/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp
+++ b/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterface.cpp
@@ -335,7 +335,7 @@ struct TestTileConsumerFuseAndYieldProducerUsingSCFForOp
     scf::ForOp outermostLoop = tilingResult->loops.front();
     for (auto [index, origVal] : llvm::enumerate(yieldedValuesToOrigValues)) {
       Value replacement = outermostLoop.getResult(index);
-      rewriter.replaceUseIf(origVal, replacement, [&](OpOperand &use) {
+      rewriter.replaceUsesWithIf(origVal, replacement, [&](OpOperand &use) {
         return !isIgnoredUser(use.getOwner(), outermostLoop);
       });
     }


        


More information about the Mlir-commits mailing list