This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Define vle/vse intrinsics.
ClosedPublic

Authored by khchen on Dec 15 2020, 7:01 PM.

Details

Summary

Define vle/vse intrinsics and lower to V instructions.

We work with @rogfer01 from BSC to come out this patch.

Authored-by: Roger Ferrer Ibanez <rofirrim@gmail.com>
Co-Authored-by: Zakk Chen <zakk.chen@sifive.com>

Diff Detail

Event Timeline

khchen created this revision.Dec 15 2020, 7:01 PM
khchen requested review of this revision.Dec 15 2020, 7:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2020, 7:01 PM
liaolucy added inline comments.
llvm/include/llvm/IR/IntrinsicsRISCV.td
87

There are two variants of intrinsics regarding to vl, https://github.com/riscv/rvv-intrinsic-doc/blob/master/rvv-intrinsic-rfc.md#vl-argument
Any suggestions for implementing implicit vl intrinsics? What existing code can be reused?

craig.topper added inline comments.Dec 15 2020, 10:27 PM
llvm/include/llvm/IR/IntrinsicsRISCV.td
205

Do we really need a separate intrinsic for each eew? Can't we infer eew from the element type of the result?

craig.topper added inline comments.Dec 15 2020, 10:39 PM
llvm/include/llvm/IR/IntrinsicsRISCV.td
87

We've been modelling this in our codebase by passing a readvl intrinsic to the vl argument of the intrinsics defined here. But that's interfering with some optimizations.

I'm not sure what the best way to implement the intrinsics that don't take a vl argument is. Since the middle end can't model the data flow of a hidden VL register we would need to mark all the intrinsics that use a hidden vl as "having side effects" so they don't get reordered around vsetvl intrinsics. The side effect flag will also prevent optimization. It also means you can't mix intrinsics that take a vl argument with intrinsics that use the current vl without also marking the intrinsics that take vl argument as having side effects.

khchen updated this revision to Diff 312186.Dec 16 2020, 5:27 AM

address @craig.topper's comment

khchen marked 3 inline comments as done.Dec 16 2020, 5:47 AM
khchen added inline comments.
llvm/include/llvm/IR/IntrinsicsRISCV.td
87

Yes, just like Craig's comment, we use a wrapper as below to model implict vl intrinsics, but there is a performance issue in this approach.

#define vadd_vv_i32m8_vl(...) __builtin_rvv_vadd_vv_i32m8_vl(__VA_ARGS__)

#define vadd_vv_i32m8(op0, op1) __builtin_rvv_vadd_vv_i32m8_vl( \
(__rvv_int32m8_t)(op0), \
(__rvv_int32m8_t)(op1), \
(size_t)(__builtin_rvv_vreadvl()))

intrinsic spec does not force implementation must support both approaches (explicit or Implicit), so I think maybe start with supporting explicit vl api is fine.

205

fixed, thanks!

This revision is now accepted and ready to land.Dec 16 2020, 10:28 AM
This revision was landed with ongoing or failed builds.Dec 16 2020, 6:08 PM
This revision was automatically updated to reflect the committed changes.
khchen marked an inline comment as done.