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

James Newling via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jun 6 08:30:30 PDT 2025


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

Thanks for the (additional!) explanation, I think I understand now
In 

```
int64_t firstDimToCollapse = std::max(
        lastDynIndex(sourceType.getShape()),
        sourceType.getRank() - sourceType.getNumContiguousTrailingDims());
```
when might 

`lastDynIndex(sourceType.getShape())` be larger than `sourceType.getRank() - sourceType.getNumContiguousTrailingDims())` ? 

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

Ok. Maybe it is simpler in these 2 senses. I guess minimising change (compared to pre-PR and to pre-pass) could be another metric.

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


More information about the llvm-branch-commits mailing list