diff --git a/compiler/src/iree/compiler/Codegen/LLVMCPU/LLVMCPUMmt4dVectorLowering.cpp b/compiler/src/iree/compiler/Codegen/LLVMCPU/LLVMCPUMmt4dVectorLowering.cpp index 2159090e47cd..ec0c013ca22b 100644 --- a/compiler/src/iree/compiler/Codegen/LLVMCPU/LLVMCPUMmt4dVectorLowering.cpp +++ b/compiler/src/iree/compiler/Codegen/LLVMCPU/LLVMCPUMmt4dVectorLowering.cpp @@ -162,6 +162,16 @@ void LLVMCPUMmt4dVectorLoweringPass::runOnOperation() { return signalPassFailure(); } } + + // 'vector.shape_cast' are very expensive operations that are even generated + // by some of the lowerings above (e.g., flatten transfer ops). There are + // chances to cancel them out if they are not lowered too early so we lower + // them at the very end of the pass. + { + RewritePatternSet patterns(&getContext()); + vector::populateVectorShapeCastLoweringPatterns(patterns); + (void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns)); + } } std::unique_ptr>