[Mlir-commits] [mlir] [mlir][vector] Fix tensor transfer hoisting with mismatched masks or permutation maps (PR #234878)
Matthias Springer
llvmlistbot at llvm.org
Tue Nov 3 08:54:25 PST 2026
matthias-springer wrote:
Would something like this work?
```
--- a/mlir/lib/Dialect/Vector/Transforms/SubsetOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/SubsetOpInterfaceImpl.cpp
@@ -16,10 +16,33 @@
namespace {
+// A masked transfer need not access the entire rectangular transfer chunk.
+static bool isMaskedTransfer(VectorTransferOpInterface transfer) {
+ return transfer.getMask() ||
+ cast<MaskableOpInterface>(transfer.getOperation()).isMasked();
+}
+
template <typename OpTy>
struct XferOpSubsetOpInterface
: public SubsetOpInterface::ExternalModel<XferOpSubsetOpInterface<OpTy>,
OpTy> {
+ bool operatesOnEquivalentSubset(
+ Operation *op, SubsetOpInterface candidate,
+ function_ref<bool(Value, Value)> equivalenceFn) const {
+ auto transfer = cast<VectorTransferOpInterface>(op);
+ if (isMaskedTransfer(transfer))
+ return false;
+ if (auto other =
+ dyn_cast<VectorTransferOpInterface>(candidate.getOperation())) {
+ if (isMaskedTransfer(other) ||
+ transfer.getVectorType() != other.getVectorType() ||
+ transfer.getPermutationMap() != other.getPermutationMap())
+ return false;
+ }
+ return mlir::detail::defaultOperatesOnEquivalentSubset(op, candidate,
+ equivalenceFn);
+ }
+
FailureOr<HyperrectangularSlice>
getAccessedHyperrectangularSlice(Operation *op) const {
auto xferOp = cast<OpTy>(op);
```
https://github.com/llvm/llvm-project/pull/234878
More information about the Mlir-commits
mailing list