[llvm-branch-commits] [mlir] [MLIR] Fix incorrect slice contiguity inference in `vector::isContiguousSlice` (PR #142422)

Momchil Velikov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jun 6 05:43:16 PDT 2025


================
@@ -630,7 +639,10 @@ class FlattenContiguousRowMajorTransferReadPattern
     if (transferReadOp.getMask())
       return failure();
 
-    int64_t firstDimToCollapse = sourceType.getRank() - vectorType.getRank();
----------------
momchil-velikov wrote:

With leading unit dimensions of a vector, the memref might not even be contiguous on that many dimensions.
Example: `memref<2x2x2xi8, strided<[8, 4, 1]>` and `vector<1x1x2xi8>`

Another consideration, in principle a memref can be collapsed in several different ways for given memref and vector types, anywhere from losing just one dimension to just one dimension remaining.

I've chosen to do maximum collapsing, as it seems simpler to do, and the resulting IR is arguably simpler.

https://github.com/llvm/llvm-project/pull/142422


More information about the llvm-branch-commits mailing list