[mlir][bufferization] Better propagation of bufferizesToMemoryWrite through regions
authorMatthias Springer <springerm@google.com>
Mon, 13 Feb 2023 15:35:47 +0000 (16:35 +0100)
committerMatthias Springer <springerm@google.com>
Mon, 13 Feb 2023 15:52:26 +0000 (16:52 +0100)
commit00a5ae12448e6f33e40c38afd640eafdb7dab212
treef74a487a17de11f3a06dde21dc6e95f447f8ed6b
parent95526930da6c00f6f12816d1f99bdf99980c387f
[mlir][bufferization] Better propagation of bufferizesToMemoryWrite through regions

`bufferizesToMemoryWrite(OpResult)` looks for OpOperands that bufferize to memory writes inside the region of the defining op (if it has one). Currently, if the reverse use-def chain stops at any value inside of the region, the OpResult is considered to bufferize to a memory write.

It is always safe to have false positives among `bufferizesToMemoryWrite`, so the previous implementation is also correct. However, it can lead to additional buffer copies.

Differential Revision: https://reviews.llvm.org/D142223
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
mlir/test/Dialect/SCF/one-shot-bufferize.mlir