[mlir][linalg][bufferize] Fix insertion point InitTensorElimination
authorMatthias Springer <springerm@google.com>
Sun, 30 Jan 2022 13:19:06 +0000 (22:19 +0900)
committerMatthias Springer <springerm@google.com>
Sun, 30 Jan 2022 13:25:39 +0000 (22:25 +0900)
commit6700a26d5f349c05a38d47a555ba2b24b5b3fcec
tree270e130d1ac3250ff629ed2b3777e6f25e172d89
parentab0554b2ec0b0c0904a6984ecc17b8f92192b3d3
[mlir][linalg][bufferize] Fix insertion point InitTensorElimination

There was a bug where some of the OpOperands needed in the replacement op were not in scope.

It does not matter where the replacement op is inserted. Any insertion point is OK as long as there are no dominance errors. In the worst case, the newly inserted op will bufferize out-of-place. This is no worse than not eliminating the InitTensorOp at all.

Differential Revision: https://reviews.llvm.org/D117685
mlir/include/mlir/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.h
mlir/lib/Dialect/Linalg/ComprehensiveBufferize/LinalgInterfaceImpl.cpp
mlir/test/Dialect/Linalg/comprehensive-module-bufferize-init-tensor-elimination.mlir