diff --git a/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h b/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h --- a/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h +++ b/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h @@ -48,9 +48,9 @@ // applyPatternsGreedily //===----------------------------------------------------------------------===// -/// Rewrite the regions of the specified operation, which must be isolated from -/// above, by repeatedly applying the highest benefit patterns in a greedy -/// work-list driven manner. +/// Rewrite the regions of the specified operation by repeatedly applying the +/// highest benefit patterns in a greedy work-list driven manner. Only ops that +/// are inside one of given regions are added to the work-list. /// /// This variant may stop after a predefined number of iterations, see the /// alternative below to provide a specific number of iterations before stopping @@ -68,7 +68,7 @@ MutableArrayRef regions, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config = GreedyRewriteConfig()); -/// Rewrite the given regions, which must be isolated from above. +/// Rewrite the given regions. inline LogicalResult applyPatternsAndFoldGreedily( Operation *op, const FrozenRewritePatternSet &patterns, GreedyRewriteConfig config = GreedyRewriteConfig()) { diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -432,11 +432,10 @@ return failure(); } -/// Rewrite the regions of the specified operation, which must be isolated from -/// above, by repeatedly applying the highest benefit patterns in a greedy -/// work-list driven manner. Return success if no more patterns can be matched -/// in the result operation regions. Note: This does not apply patterns to the -/// top-level operation itself. +/// Rewrite the regions of the specified operation by repeatedly applying the +/// highest benefit patterns in a greedy work-list driven manner. Return success +/// if no more patterns can be matched in the result operation regions. +/// Note: This does not apply patterns to the top-level operation itself. /// LogicalResult mlir::applyPatternsAndFoldGreedily(MutableArrayRef regions, @@ -445,16 +444,6 @@ if (regions.empty()) return success(); - // The top-level operation must be known to be isolated from above to - // prevent performing canonicalizations on operations defined at or above - // the region containing 'op'. - auto regionIsIsolated = [](Region ®ion) { - return region.getParentOp()->hasTrait(); - }; - (void)regionIsIsolated; - assert(llvm::all_of(regions, regionIsIsolated) && - "patterns can only be applied to operations IsolatedFromAbove"); - // Start the pattern driver. GreedyPatternRewriteDriver driver(regions[0].getContext(), patterns, config); bool converged = driver.simplify(regions);