[PATCH] D149916: [VP][SelectionDAG][RISCV] Add get_vector_length intrinsics and generic SelectionDAG support.

Roger Ferrer Ibanez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 19 03:40:03 PDT 2023


rogfer01 added a comment.

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 at: llvm/docs/LangRef.rst:18092
+
+Returns a positive value (explicit vector length) that is unknown at compile
+time and depends on the hardware specification.
----------------
I'd emphasise the fact that we always return an `i32`, this may be easy to miss from the two instances in the Syntax section.


================
Comment at: llvm/docs/LangRef.rst:18097
+
+If the total count is larger than VF*vscale, this intrinsic may not return
+VF*vscale. The result will be at least as large as the result for any value
----------------
I think we want to explain that when `cnt ≤ (vscale * VF)` (for now, assume `vscale = 1` if we're dealing with fixed vectors). We understand in this case the result of this intrinsic is `cnt`.

Also the case for `cnt > (vscale * VF)` is worded in a bit of an obscure way and might not be true as we understand it. For the specific case of RISC-V, if `VLMAX=64`, `cnt=64` will return `64` but `cnt=65` may return a value `x` ∊ (32, 64], like 33. That would not be a result "at least as large as the result for any value less than count" (we understand "any value less than count" as a value ∊ [0, 64]). Maybe we got it wrong.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149916/new/

https://reviews.llvm.org/D149916



More information about the llvm-commits mailing list