[Mlir-commits] [mlir] [mlir][vector] Patterns to convert to shape_cast, where possible (PR #138777)

James Newling llvmlistbot at llvm.org
Tue May 13 09:10:37 PDT 2025


newling wrote:

Ok i might give that a try, starting with transpose->shape_cast on the transpose canonicalizer. I'm not entirely sure what a formal definition of 'no data movement' in SSA might be. The shape_cast still has to lower to something in LLVM, it's only during register allocation that it will vanish. I guess ideally all shape_casts will have been canonicalized away, especially when using linearization/flattening. 

I mentioned this previously and it's probably over-the-top at the moment but at some point it'd be nice to add something to the docs describing the canonicalization rules, like

```
## Canonicalization rules

To ensure that canonicalization converges to a fixed point, we define a preference 
list on vector dialect operations. Operations higher in the list are preferred. 
- vector.shape_cast
- vector.broadcast
- vector.transpose
```
Patterns that substitute one operation with another must satisfy the above list 
```

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


More information about the Mlir-commits mailing list