[Mlir-commits] [mlir] [mlir][vector] Support multi-dimensional vectors in VectorFromElementsLowering (PR #151175)
Yang Bai
llvmlistbot at llvm.org
Fri Aug 8 01:24:36 PDT 2025
yangtetris wrote:
IIUC, we now have two ways to convert vector to LLVM:
1. convert-vector-to-llvm pass. It includes two stages: a transformation stage that "lowers vector ops to other vector ops", and a conversion that "lowers vector ops to LLVM ops".
2. convert-to-llvm: only includes the latter conversion stage.
We only need to support lowering multi-dim from_elements ops in convert-vector-to-llvm. Please correct me if I'm wrong.
> Expanding populateVectorShapeCastLoweringPatterns (or creating patterns that inject vector.shape_cast and then leveraging populateVectorShapeCastLoweringPatterns) less so - wouldn't we be simply shifting the complexity within vector-to-llvm (as opposed to making it simpler)?
Our goal is keeping the conversion stage simple, right? So it is ok to shift the complexity to `populateVectorShapeCastLoweringPatterns` or `populateVectorFromElementsOpLoweringPatterns`, which both belong to the transformation stage.
> Or my suggestion was to add a pattern there to split a rank-D from_elements op into a rank-1 from_elements op preceded by a shape_cast, and then populateVectorShapeCastLoweringPatterns will kick in and generate the inserts/extracts.
Using shapecast or iteratively unrolling N-D vectors are both ok for me. I'd like to do some experiments to study which method can generate more efficient operations.
https://github.com/llvm/llvm-project/pull/151175
More information about the Mlir-commits
mailing list