diff --git a/compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp b/compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp index 5fbb05fe5ed77..2edda4db9ae7b 100644 --- a/compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp +++ b/compiler/src/iree/compiler/Codegen/LLVMCPU/Passes.cpp @@ -507,8 +507,16 @@ void addMultiTilingExpertPassPipeline( nestedModulePM.addNestedPass(createCSEPass()); } + // Eliminate redundant transfer_read/write to avoid stack allocations. + nestedModulePM.addNestedPass( + createOptimizeVectorTransferPass(/*flatten=*/false)); + addBufferizePasses(nestedModulePM); + // Perform memref-based transfer_read/write optimizations. + nestedModulePM.addNestedPass( + createOptimizeVectorTransferPass(/*flatten=*/false)); + // Run IREE specific passes before vector lowering expert. nestedModulePM.addNestedPass( createRemoveSingleIterationLoopPass()); @@ -655,8 +663,16 @@ void addCPUDataTilingPipeline(OpPassManager &passManager, nestedModulePM.addNestedPass(createCSEPass()); } + // Eliminate redundant transfer_read/write to avoid stack allocations. + nestedModulePM.addNestedPass( + createOptimizeVectorTransferPass(/*flatten=*/false)); + addBufferizePasses(nestedModulePM); + // Perform memref-based transfer_read/write optimizations. + nestedModulePM.addNestedPass( + createOptimizeVectorTransferPass(/*flatten=*/false)); + { LLVMCPUVectorLoweringPassOptions options; options.splitVectorTransfersTo = "linalg-copy";