Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/gc/Transforms/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,28 @@ void populateVectorPasses(mlir::OpPassManager &pm) {

// scf + arith + math + vector + memref + linalg.brgemm
void populateBufferizationPasses(mlir::OpPassManager &pm) {
// The flow follows https://mlir.llvm.org/docs/Bufferization/#overview
pm.addPass(bufferization::createEmptyTensorEliminationPass());
bufferization::OneShotBufferizationOptions options;
options.bufferizeFunctionBoundaries = true;
options.setFunctionBoundaryTypeConversion(
bufferization::LayoutMapOption::IdentityLayoutMap);
pm.addPass(bufferization::createOneShotBufferizePass(options));
pm.addPass(createCanonicalizerPass());
pm.addPass(createCSEPass());
pm.addPass(createCanonicalizerPass());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L101 is already CanonicalizerPass, do we really need to do it again after CSE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the first CanonicalizerPass is mainly used to canonicalize the scf.for and scf.forall to the canonical form in memref, exposing more CSE optimization opportunities. The CSE pass is used to eliminate the common memref.subview so there will be some useless memref.copy memref.copy %a, %a. The last CanonicalizerPass is used to eliminate the useless memref.copy which copies from A to A like memref.copy %a, %a

pm.addNestedPass<func::FuncOp>(bufferization::createBufferHoistingPass());
pm.addNestedPass<func::FuncOp>(bufferization::createBufferLoopHoistingPass());
// todo: buffer schedule pass
// todo: Need to improve this pass to support nested parallel.
bufferization::BufferResultsToOutParamsOpts opt{};
opt.hoistStaticAllocs = true;
pm.addPass(bufferization::createBufferResultsToOutParamsPass(opt));
// todo: buffer schedule pass
// todo: Need to improve this pass to support nested parallel.
pm.addNestedPass<func::FuncOp>(bufferization::createBufferHoistingPass());
pm.addNestedPass<func::FuncOp>(bufferization::createBufferLoopHoistingPass());
pm.addNestedPass<func::FuncOp>(bufferization::createBufferDeallocationPass());
pm.addPass(bufferization::createDropEquivalentBufferResultsPass());
pm.addNestedPass<func::FuncOp>(
bufferization::createPromoteBuffersToStackPass());
bufferization::BufferDeallocationPipelineOptions deallocOption;
bufferization::buildBufferDeallocationPipeline(pm, deallocOption);
pm.addPass(createBufferizationToMemRefPass());
populateCleanUpPasses(pm);
}
Expand Down