From ced97ffd0899a3faff796170ed778723efcf8a5b Mon Sep 17 00:00:00 2001 From: Benjamin Maxwell Date: Mon, 13 Nov 2023 11:22:55 +0000 Subject: [PATCH] [mlir][Vector] Don't fully unroll transfer_writes of n-D scalable vectors (#71924) It is not possible to unroll a scalable vector at compile time. This currently prevents transfer_writes from being lowered to arm_sme.tile_writes (downstream). --- mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp | 5 +++++ mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp index 5fffd9091d22..18d6292754f1 100644 --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -1218,6 +1218,11 @@ struct UnrollTransferWriteConversion auto vec = getDataVector(xferOp); auto xferVecType = xferOp.getVectorType(); + if (xferVecType.getScalableDims()[0]) { + // Cannot unroll a scalable dimension at compile time. + return failure(); + } + int64_t dimSize = xferVecType.getShape()[0]; Value source = xferOp.getSource(); // memref or tensor to be written to. auto sourceType = isTensorOp(xferOp) ? xferOp.getShapedType() : Type(); diff --git a/mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir b/mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir index 4880532c5528..597cc4f71a63 100644 --- a/mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir +++ b/mlir/test/Conversion/VectorToSCF/vector-to-scf.mlir @@ -737,4 +737,14 @@ func.func @cannot_lower_transfer_read_with_leading_scalable(%arg0: memref) // CHECK: %{{.*}} = vector.transfer_read %[[MEMREF]][%{{.*}}, %{{.*}}], %{{.*}}, %{{.*}} {in_bounds = [true, true]} : memref, vector<[4]x4xf32> +// ----- +// FULL-UNROLL-LABEL: @cannot_fully_unroll_transfer_write_of_nd_scalable_vector +func.func @cannot_fully_unroll_transfer_write_of_nd_scalable_vector(%vec: vector<[4]x[4]xf32>, %memref: memref) { + // FULL-UNROLL-NOT: vector.extract + // FULL-UNROLL: vector.transfer_write {{.*}} : vector<[4]x[4]xf32>, memref + // FULL-UNROLL-NOT: vector.extract + %c0 = arith.constant 0 : index + vector.transfer_write %vec, %memref[%c0, %c0] {in_bounds = [true, true]} : vector<[4]x[4]xf32>, memref + return +}