[Mlir-commits] [mlir] [mlir][vector] Canonicalize/fold 'order preserving' transposes (PR #135841)

James Newling llvmlistbot at llvm.org
Wed Apr 30 09:54:28 PDT 2025


newling wrote:

Thanks @banach-space I'll address these comments, but just to mention that there still is test that fails (hangs) for me, it is `test/Dialect/ArmSME/vector-legalization.mlir`

The problem is that the pattern ConvertIllegalShapeCastOpsToTransposes converts 

```
%0 = shape_cast [4]x1 -> [4]
```

into
 
```
%0 = transpose [4]x1 -> 1x[4]
%1 = shape_cast 1x[4] -> [4]
```

but the canonicalizer added here does the exact reverse! So we get an infinite loop. 

The place where this transformation happens: 

https://github.com/llvm/llvm-project/blob/8e4dd21e6362ca161b7fda4fe7c5fa20f72ffab2/mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp#L770

I've tried to dig a bit deeper, but don't see where shape_cast gets further lowered (I was wondering if  `shape_cast [4]x1 -> [4]` could be lowered as it is without the need for ). Also wondered if maybe `shape_cast [4]x1 -> [4]` can't always be fused with its defining op? 

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


More information about the Mlir-commits mailing list