Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 09dfc57

Browse files
authoredDec 20, 2024
[mlir] Enable decoupling two kinds of greedy behavior. (llvm#104649)
The greedy rewriter is used in many different flows and it has a lot of convenience (work list management, debugging actions, tracing, etc). But it combines two kinds of greedy behavior 1) how ops are matched, 2) folding wherever it can. These are independent forms of greedy and leads to inefficiency. E.g., cases where one need to create different phases in lowering and is required to applying patterns in specific order split across different passes. Using the driver one ends up needlessly retrying folding/having multiple rounds of folding attempts, where one final run would have sufficed. Of course folks can locally avoid this behavior by just building their own, but this is also a common requested feature that folks keep on working around locally in suboptimal ways. For downstream users, there should be no behavioral change. Updating from the deprecated should just be a find and replace (e.g., `find ./ -type f -exec sed -i 's|applyPatternsAndFoldGreedily|applyPatternsGreedily|g' {} \;` variety) as the API arguments hasn't changed between the two.
1 parent 412e1af commit 09dfc57

File tree

110 files changed

+313
-246
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+313
-246
lines changed
 

‎flang/lib/Optimizer/HLFIR/Transforms/InlineElementals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class InlineElementalsPass
125125
mlir::RewritePatternSet patterns(context);
126126
patterns.insert<InlineElementalConversion>(context);
127127

128-
if (mlir::failed(mlir::applyPatternsAndFoldGreedily(
128+
if (mlir::failed(mlir::applyPatternsGreedily(
129129
getOperation(), std::move(patterns), config))) {
130130
mlir::emitError(getOperation()->getLoc(),
131131
"failure in HLFIR elemental inlining");

‎flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIRIntrinsics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,8 @@ class LowerHLFIRIntrinsics
520520
config.enableRegionSimplification =
521521
mlir::GreedySimplifyRegionLevel::Disabled;
522522

523-
if (mlir::failed(mlir::applyPatternsAndFoldGreedily(
524-
module, std::move(patterns), config))) {
523+
if (mlir::failed(
524+
mlir::applyPatternsGreedily(module, std::move(patterns), config))) {
525525
mlir::emitError(mlir::UnknownLoc::get(context),
526526
"failure in HLFIR intrinsic lowering");
527527
signalPassFailure();

0 commit comments

Comments
 (0)
Please sign in to comment.