From a9d7610f9d6740e984cbeb55854abac1f92414f9 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Mon, 13 Jul 2020 16:15:42 -0700 Subject: [PATCH] Cleanup after going to `llvm` dialect. This reduces IR size a lot, which can help when staring at it. --- lib/E2E/E2E.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/E2E/E2E.cpp b/lib/E2E/E2E.cpp index 803ce6d3a..5ae64ac96 100644 --- a/lib/E2E/E2E.cpp +++ b/lib/E2E/E2E.cpp @@ -432,7 +432,7 @@ void mlir::NPCOMP::createE2ELoweringPipeline( // pass that checks no !shape.shape types left. pm.addPass(createLowerRankedShapesPass()); - // Run a some final cleanups. + // Run a some cleanups. if (options.optimize) { pm.addPass(createCanonicalizerPass()); pm.addPass(createCSEPass()); @@ -449,4 +449,11 @@ void mlir::NPCOMP::createE2ELoweringPipeline( // which reuses the upstream patterns and gives us a place to add our own // patterns for any custom ops and types we wish to lower. pm.addPass(createLowerToLLVMPass()); + + // Although LLVM will clean everything up eventually, for the sake of IR + // clarity while still in MLIR, run some cleanups. + if (options.optimize) { + pm.addPass(createCanonicalizerPass()); + pm.addPass(createCSEPass()); + } }