The generic implementation is umin(TC, VF * vscale).
Lowering to vsetvli for RISC-V will come in a future patch.
This patch is a pre-requisite to be able to CodeGen vectorized code from
D99750.
Differential D149916
[VP][SelectionDAG][RISCV] Add get_vector_length intrinsics and generic SelectionDAG support. craig.topper on May 4 2023, 3:54 PM. Authored by
Details The generic implementation is umin(TC, VF * vscale). Lowering to vsetvli for RISC-V will come in a future patch. This patch is a pre-requisite to be able to CodeGen vectorized code from
Diff Detail
Event TimelineComment Actions I suppose this makes sense for ARM MVE/SVE as well? Comment Actions -Add SVE test.
Comment Actions It looks good to me, but I'd like to leave it open for a bit so that other more active reviewers can take a look.
Comment Actions Thanks @craig.topper. This went under our radar. Apologies. In general this makes sense, but if we want this to be useful for the VE target we need to address the fixed vector case. Being able to set the vector length is orthogonal to scalable vectors. We assume that a call to llvm.experimental.get.vector.length for VE (or any other fixed-vector target with vector length) would set the cnt parameter, might optionally use the element_width parameter and then the vector factor would not be scaled by vscale. The user of the intrinsic, like the loop vectorizer, would have already chosen a meaningful value for vf for VE (VE for instance can use vf=256 when operating with 64-bit element width). However this would render the intrinsic a bit ambiguous between fixed and scalable. Maybe we can add an additional parameter stating if the VF is actually scaled by vscale or not (e.g., an immarg i1 or maybe a metadata string operand)?
Comment Actions This looks reasonable to me, minor comments only.
Comment Actions LGTM p.s. It would be helpful to land this even well in advance of the vectorizer changes. That would lets us write code gen test cases for both variants of VP predication being discussed, and see what we can get code generation to look like. Comment Actions I think we are going to need that, but I'm happy to take advantage of this being an experimental intrinsic and iterating in tree, so LGTM either way. |
Double comma here