[Mlir-commits] [mlir] [mlir][Vector] Fix `vector.shuffle` folder for poison indices (PR #124863)
Jakub Kuderski
llvmlistbot at llvm.org
Tue Jan 28 16:46:15 PST 2025
================
@@ -2673,43 +2673,51 @@ static bool isStepIndexArray(ArrayRef<T> idxArr, uint64_t begin, size_t width) {
}
OpFoldResult vector::ShuffleOp::fold(FoldAdaptor adaptor) {
- VectorType v1Type = getV1VectorType();
+ auto v1Type = getV1VectorType();
+ auto v2Type = getV2VectorType();
+
+ assert(!v1Type.isScalable() && !v2Type.isScalable() &&
+ "Vector shuffle does not support scalable vectors");
+
// For consistency: 0-D shuffle return type is 1-D, this cannot be a folding
// but must be a canonicalization into a vector.broadcast.
if (v1Type.getRank() == 0)
return {};
- // fold shuffle V1, V2, [0, 1, 2, 3] : <4xi32>, <2xi32> -> V1
- if (!v1Type.isScalable() &&
- isStepIndexArray(getMask(), 0, v1Type.getDimSize(0)))
+ // Fold shuffle V1, V2, [0, 1, 2, 3] : <4xi32>, <2xi32> -> V1.
+ if (isStepIndexArray(getMask(), 0, v1Type.getDimSize(0)))
----------------
kuhar wrote:
nit: hoist mask and dim sizes into local variables, since these are queried multiple times in this function?
https://github.com/llvm/llvm-project/pull/124863
More information about the Mlir-commits
mailing list