diff --git a/compiler/src/iree/compiler/GlobalOptimization/Passes.cpp b/compiler/src/iree/compiler/GlobalOptimization/Passes.cpp index cf28b348058ec..6897a981b8767 100644 --- a/compiler/src/iree/compiler/GlobalOptimization/Passes.cpp +++ b/compiler/src/iree/compiler/GlobalOptimization/Passes.cpp @@ -28,6 +28,14 @@ void buildGlobalOptimizationPassPipeline( .addPass(mlir::createLinalgNamedOpConversionPass) .addPass(IREE::Flow::createConvert1X1FilterConv2DToMatmulPass); mainPassManager.addPass(IREE::Flow::createEraseUnusedLinalgOperands()); + + // Expand tensor shapes into SSA values and optimize the whole program. + // The more we are able to equate shape dimensions at this level the + // better our fusions will be. + FunctionLikeNest(mainPassManager) + .addPass(IREE::Flow::createTopLevelSCFToCFGPass); + mainPassManager.addPass(IREE::Flow::createExpandTensorShapesPass()); + FunctionLikeNest(mainPassManager) // Preprocess the input to a form more amenable for fusion // - Convert all elementwise ops to Linalg @@ -43,13 +51,6 @@ void buildGlobalOptimizationPassPipeline( .addPass(mlir::createCanonicalizerPass) .addPass(mlir::createCSEPass); - // Expand tensor shapes into SSA values and optimize the whole program. - // The more we are able to equate shape dimensions at this level the - // better our fusions will be. - FunctionLikeNest(mainPassManager) - .addPass(IREE::Flow::createTopLevelSCFToCFGPass); - mainPassManager.addPass(IREE::Flow::createExpandTensorShapesPass()); - OpPassManager pipeline(ModuleOp::getOperationName()); FunctionLikeNest(pipeline) // Simplify util.global accesses early on; this can help with dispatch