[Mlir-commits] [mlir] [mlir][vector] Canonicalize transfer_{read, write} vector<1xT> (PR #196598)
Erick Ochoa Lopez
llvmlistbot at llvm.org
Mon May 11 07:46:55 PDT 2026
================
@@ -5625,11 +5625,54 @@ struct TransferReadAfterWriteToBroadcast
return success();
}
};
+/// Canonicalize a rank-1, single-element vector transfer so that its
+/// permutation map is the minor identity.
+///
+/// When the vector type is `vector<1xT>`, the permutation map is irrelevant
+/// to which element is accessed: the single vector lane has iteration offset 0,
+/// so the element is always at `indices` regardless of which source dimension
+/// the map points at. Replacing the map with the minor identity unblocks
+/// lowering to vector.load / vector.store.
+template <typename TransferOp>
+struct CanonicalizeSize1TransferPermutationMap final
+ : OpRewritePattern<TransferOp> {
+ using OpRewritePattern<TransferOp>::OpRewritePattern;
+
+ LogicalResult matchAndRewrite(TransferOp op,
+ PatternRewriter &rewriter) const override {
+ VectorType vecType = op.getVectorType();
+ if (vecType.getRank() != 1 || vecType.getShape()[0] != 1)
----------------
amd-eochoalo wrote:
You are right! Thanks! https://github.com/llvm/llvm-project/pull/196598/commits/0bd5e3310b015acd164f86b72f165883c4b96281
https://github.com/llvm/llvm-project/pull/196598
More information about the Mlir-commits
mailing list