diff options
Diffstat (limited to 'mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp')
-rw-r--r-- | mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index f9a9be5..e40a4d9 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -10,9 +10,8 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Dialect/StandardOps/IR/Ops.h" -#include "mlir/IR/Builders.h" #include "mlir/IR/PatternMatch.h" +#include "mlir/Interfaces/SideEffects.h" #include "mlir/Transforms/FoldUtils.h" #include "mlir/Transforms/RegionUtils.h" #include "llvm/ADT/DenseMap.h" @@ -162,11 +161,8 @@ bool GreedyPatternRewriteDriver::simplify(MutableArrayRef<Region> regions, if (op == nullptr) continue; - // If the operation has no side effects, and no users, then it is - // trivially dead - remove it. - if (op->isKnownNonTerminator() && op->hasNoSideEffect() && - op->use_empty()) { - // Be careful to update bookkeeping. + // If the operation is trivially dead - remove it. + if (isOpTriviallyDead(op)) { notifyOperationRemoved(op); op->erase(); continue; @@ -204,7 +200,10 @@ bool GreedyPatternRewriteDriver::simplify(MutableArrayRef<Region> regions, // After applying patterns, make sure that the CFG of each of the regions is // kept up to date. - changed |= succeeded(simplifyRegions(regions)); + if (succeeded(simplifyRegions(regions))) { + folder.clear(); + changed = true; + } } while (changed && ++i < maxIterations); // Whether the rewrite converges, i.e. wasn't changed in the last iteration. return !changed; |