Skip to content

Commit b49c0b8

Browse files
authored
[mlir][ArmSME] Simplify permutation map handling (#93515)
In -convert-vector-to-arm-sme the permutation_map is explicitly checked for transpose when converting xfer ops, but for 2-D vector types the only non-identity permutation map is transpose so this can be simplified.
1 parent 8b600a3 commit b49c0b8

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

mlir/lib/Conversion/VectorToArmSME/VectorToArmSME.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,18 @@ struct TransferReadToArmSMELowering
6565
return rewriter.notifyMatchFailure(transferReadOp,
6666
"not inbounds transfer read");
6767

68-
arm_sme::TileSliceLayout layout;
69-
70-
AffineExpr d0, d1;
71-
bindDims(transferReadOp.getContext(), d0, d1);
7268
AffineMap map = transferReadOp.getPermutationMap();
73-
if (map.isIdentity())
74-
layout = arm_sme::TileSliceLayout::Horizontal;
75-
else if (map == AffineMap::get(map.getNumDims(), 0, {d1, d0},
76-
transferReadOp.getContext()))
77-
layout = arm_sme::TileSliceLayout::Vertical;
78-
else
69+
if (!map.isPermutation())
7970
return rewriter.notifyMatchFailure(transferReadOp,
8071
"unsupported permutation map");
8172

73+
// Note: For 2D vector types the only non-identity permutation is a simple
74+
// transpose [1, 0].
75+
bool transposed = !map.isIdentity();
76+
arm_sme::TileSliceLayout layout =
77+
transposed ? arm_sme::TileSliceLayout::Vertical
78+
: arm_sme::TileSliceLayout::Horizontal;
79+
8280
// Padding isn't optional for transfer_read, but is only used in the case
8381
// of out-of-bounds accesses (not supported here) and/or masking. Mask is
8482
// optional, if it's not present don't pass padding.
@@ -137,19 +135,17 @@ struct TransferWriteToArmSMELowering
137135
return rewriter.notifyMatchFailure(writeOp,
138136
"not inbounds transfer write");
139137

140-
AffineExpr d0, d1;
141-
bindDims(writeOp.getContext(), d0, d1);
142138
AffineMap map = writeOp.getPermutationMap();
143-
bool isTranspose = (map == AffineMap::get(map.getNumDims(), 0, {d1, d0},
144-
writeOp.getContext()));
145-
146-
if (!map.isIdentity() && !isTranspose)
139+
if (!map.isPermutation())
147140
return rewriter.notifyMatchFailure(writeOp,
148141
"unsupported permutation map");
149142

143+
// Note: For 2D vector types the only non-identity permutation is a simple
144+
// transpose [1, 0].
145+
bool transposed = !map.isIdentity();
150146
arm_sme::TileSliceLayout layout =
151-
isTranspose ? arm_sme::TileSliceLayout::Vertical
152-
: arm_sme::TileSliceLayout::Horizontal;
147+
transposed ? arm_sme::TileSliceLayout::Vertical
148+
: arm_sme::TileSliceLayout::Horizontal;
153149

154150
rewriter.replaceOpWithNewOp<arm_sme::TileStoreOp>(
155151
writeOp, writeOp.getVector(), writeOp.getSource(), writeOp.getIndices(),

0 commit comments

Comments
 (0)