[Mlir-commits] [mlir] [mlir][vector] Fold vector extract from insert when trailing unit dims (PR #192109)
Diego Caballero
llvmlistbot at llvm.org
Wed Apr 15 09:01:27 PDT 2026
dcaballe wrote:
> > The folding makes sense to me but I think we should generate a `vector.from_elements ... : vector<1xf32>`. We've been using that and insert/extract to cross the scalar/vector boundary and we have more folder/canonicalization patters on that front that could simplify the code further.
>
> Not sure if that works for:
>
> ```
> %vec1 = vector.insert %src into %vec[0, 0] : vector<1xf32> into vector<16x1x1xf32>
> %vec2 = vector.extract %vec1[0] : vector<1x1xf32> from vector<16x1x1xf32>
> ```
>
> This can be written as:
>
> ```
> %vec2 = vector.broadcast %src : vector<1xf32> to vector<1x1xf32>
> ```
This is a different case that is not crossing the scalar/vector boundary and would be turned into a `vector.shape_cast` by other folders/canonicalization patterns, IIRC.
https://github.com/llvm/llvm-project/pull/192109
More information about the Mlir-commits
mailing list