[Mlir-commits] [mlir] [mlir][tensor] Apply `InsertSliceOfTransferWriteOpFolder` only when `transfer_write` overwrites all elements of `insert_slice` (PR #108803)

Benjamin Maxwell llvmlistbot at llvm.org
Mon Sep 30 02:02:03 PDT 2024


================
@@ -84,6 +88,15 @@ static LogicalResult preconditionsFoldExtractOrInsertWithTransferOp(
                 "strides, this may result in needing to insert "
                 "vector.insert_strided_slice/extract_strided_slice ops");
   }
+  if constexpr (std::is_same_v<XferOp, vector::TransferWriteOp>) {
+    if constexpr (std::is_same_v<ExtractOrInsertOp, tensor::InsertSliceOp>) {
+      if (!InsertSliceOfTransferWriteOpFolder::
+              doesTransferWriteCoverInsertSlice(xferOp))
+        return rewriter.notifyMatchFailure(
+            xferOp, "transfer_write does not cover insert_slice");
+    }
+  }
----------------
MacDue wrote:

Rather than having these `if constexpr`s can't this check just be placed in `InsertSliceOfTransferWriteOpFolder`?

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


More information about the Mlir-commits mailing list