by Graham Markall

I recently attended the GNU Tools Cauldron in Manchester, where Roger Espasa from Esperanto Technologies and I ran a BoF session on GCC support for the RISC-V Vector (V) extension. This is an interesting topic, because the V extension has features that aren’t present in any other supported SIMD / Vector Architecture. This post is a short writeup of the current state of efforts towards supporting the extension in both GCC and LLVM, and some pointers to where things appear to be going.
The RISC-V Vector Extension has some interesting features. Some highlights are:
A video of one of Roger’s previous tutorials gives a nice introduction and overview of the architecture.
At present the V extension design is not yet finalised – there are still possibilities for changes to the encodings and some instructions. The current working version of the proposal is kept in the riscv-v-spec Github repository.
Robin Kruppe from TU Darmstadt has been experimenting with how LLVM can be adapted to support the V extension, in particular thinking about how to effectively make use of the changing vector length and its implications for the ABI.
An RFC discussion on the llvm-dev mailing list lays out Robin’s initial ideas involving a new IR type for supporting the vector length, and the ensuing discussion received contributions from various developers working on the SVE support. Since then, another thread started by Graham Hunter of ARM moves towards the idea of using a single unified IR type for both SVE and V extension support.
Robin described his work so far at the recent EuroLLVM conference in Bristol, UK. At present all of his work is quite experimental due to the changing nature of the specification proposal, and the need for experimentation to guide the right implementation choices, so there is presently no public code repository containing an implementation of V extension support in LLVM.
Robin shared with me (in private correspondence) a summary of the current status of his work, reproduced here (with his permission) in edited form:
<1, 1, ..., 1, 0, 0, ..., 0>) are conceivable, but more practical experience is needed. The primary concern with representing VL as a mask is instruction selection and how to ensure that one can reliably identify when an instruction is predicated by VL (either solely or by the conjunction of VL and an ordinary mask), and code-generate as such, rather than inefficiently materializing the <1, 1, ..., 1, 0, 0, ..., 0> mask. Robin is expecting to eventually make a proposal in this space.At present there has been no implementation work or experimentation conducted with GCC, and the GNU Cauldron’s BoF session marks the start of discussions about how this work could be carried out. The session led to discussion summarised in a post to the GCC mailing list by Richard Henderson. The discussion touches on the following topics:
Expect to see progress on all fronts:
Watch this space!