[Mlir-commits] [mlir] [mlir][vector] Prevent incorrect vector.transfer_{read|write} hoisting (PR #66930)

Nicolas Vasilache llvmlistbot at llvm.org
Thu Sep 28 03:04:52 PDT 2023


================
@@ -152,6 +152,14 @@ void mlir::linalg::hoistRedundantVectorTransfers(func::FuncOp func) {
           transferRead.getPermutationMap() != transferWrite.getPermutationMap())
         return WalkResult::advance();
 
+      // When the source of transfer_read aliases, the following dominance
+      // analysis might not be sufficient.
+      // TODO: There might be other, similar cases missing here (i.e. other
+      // Memref Ops). 
+      auto source = transferRead.getSource();
+      if (source.getDefiningOp<memref::CollapseShapeOp>())
----------------
nicolasvasilache wrote:

This is a bit too adhoc to my taste, can we use `ViewLikeOpInterface` to capture all the cases that may alias?

>From what I see we should also update noAliasingUseInLoop to use `ViewLikeOpInterface` and avoid enumerating an incomplete list of ops.

Lastly, you also want to add a bit more documentation to `hoistRedundantVectorTransfers` point 3. to mention that one may also want to fold aliasing memref operations into `vector.transfer` ops (in addition to LICM) to improve the hoisting.


https://github.com/llvm/llvm-project/pull/66930


More information about the Mlir-commits mailing list