[Mlir-commits] [mlir] [milr][memref]: Fold expand_shape + transfer_read (PR #167679)
Georgios Pinitas
llvmlistbot at llvm.org
Mon Nov 24 02:24:05 PST 2025
================
@@ -347,28 +347,49 @@ LogicalResult LoadOpOfExpandShapeOpFolder<OpTy>::matchAndRewrite(
loadOp.getLoc(), rewriter, expandShapeOp, indices, sourceIndices,
isa<affine::AffineLoadOp, memref::LoadOp>(loadOp.getOperation()))))
return failure();
- llvm::TypeSwitch<Operation *, void>(loadOp)
+
+ return llvm::TypeSwitch<Operation *, LogicalResult>(loadOp)
.Case([&](affine::AffineLoadOp op) {
rewriter.replaceOpWithNewOp<affine::AffineLoadOp>(
loadOp, expandShapeOp.getViewSource(), sourceIndices);
+ return success();
})
.Case([&](memref::LoadOp op) {
rewriter.replaceOpWithNewOp<memref::LoadOp>(
loadOp, expandShapeOp.getViewSource(), sourceIndices,
op.getNontemporal());
+ return success();
})
.Case([&](vector::LoadOp op) {
rewriter.replaceOpWithNewOp<vector::LoadOp>(
op, op.getType(), expandShapeOp.getViewSource(), sourceIndices,
op.getNontemporal());
+ return success();
})
.Case([&](vector::MaskedLoadOp op) {
rewriter.replaceOpWithNewOp<vector::MaskedLoadOp>(
op, op.getType(), expandShapeOp.getViewSource(), sourceIndices,
op.getMask(), op.getPassThru());
+ return success();
+ })
+ .Case([&](vector::TransferReadOp op) {
+ // We only support minor identity maps in the permutation attribute.
+ if (!op.getPermutationMap().isMinorIdentity())
+ return failure();
+
+ // We need to construct a new minor identity map since we will have lost
+ // some dimensions in folding away the expand shape.
+ auto minorIdMap = AffineMap::getMinorIdentityMap(
+ sourceIndices.size(), op.getVectorType().getRank(),
----------------
GeorgeARM wrote:
Don't you need to check that the vector ranks is compatible with the base rank after folding?
https://github.com/llvm/llvm-project/pull/167679
More information about the Mlir-commits
mailing list