[Mlir-commits] [mlir] [vector][mlir] Canonicalize to shape_cast where possible (PR #140583)
James Newling
llvmlistbot at llvm.org
Tue Dec 16 20:22:15 PST 2025
newling wrote:
Thanks @ftynse, and everyone who attended the call, I'm sorry I couldn't make it. I'm happy to create a new PR with 2 of the 3 patterns in this PR, will do so in the coming weeks.
> Alternatively, show where having shape_cast instead of transpose is beneficial.
One small advantage is that we get the following simplification for free:
```mlir
%0 = vector.shape_cast %arg0 : vector<1x2x2f32> to vector<1x4xf32>
%1 = vector.transpose %0, [1, 0] : vector<1x4xf32> to vector<4x1xf32>
%2 = vector.shape_cast %1 : vector<4x1xf32> to vector<4xf32>
```
====>
```mlir
%0 = vector.shape_cast %arg0 : vector<1x2x2f32> to vector<1x4xf32>
%1 = vector.shape_cast %0 : vector<1x4xf32> to vector<4x1xf32>
%2 = vector.shape_cast %1 : vector<4x1xf32> to vector<4xf32>
```
====>
```mlir
%2 = vector.shape_cast %arg0 : vector<1x2x2f32> to vector<4xf32>
```
https://github.com/llvm/llvm-project/pull/140583
More information about the Mlir-commits
mailing list