[PATCH] D94286: [RISCV] Add a VL output to vleff intrinsics.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 21:24:26 PST 2021


craig.topper created this revision.
craig.topper added reviewers: HsiangKai, evandro, khchen.
Herald added subscribers: frasercrmck, NickHung, luismarques, apazos, sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.

The fault-only-first-load instructions can reduce VL if an element
other than element 0 triggers a memory fault. This can be used to
vectorize loops with data dependent exit conditions like strcmp or
strlen.

This patch adds a VL output to these intrinsics so that the new
VL value can be captured by software. This will be expanded to
'csrr gpr, vl' after the vleff instruction during SelectionDAG.

By doing this with one intrinsic we are able to guarantee that the
csrr reads the VL value produced by the vleff instruction. Having
it as a separate intrinsic would make it impossible to guarantee
ordering without making every other vector intrinsic have side
effects.

The intrinsics are expanded during lowering into two ISD nodes
that are glued and chained together. These ISD nodes will go
through isel separately, but should maintain the glue so that they
get emitted adjacent by InstrEmitter.

I'm not sure we really need the chain through the READ_VL node.
Having the chain prevents it from being removed if it isn't used.
That might be too conservative in some case, but most likely
you'll need to use the vl to adjust a pointer. I'm also not sure
we need HasSideEffects on these instructions, the register dependency
might be enough, but I'd like to play it safe for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94286

Files:
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/CodeGen/Analysis.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/vleff-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vleff-rv64.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94286.315296.patch
Type: text/x-patch
Size: 188108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210108/9aa73b18/attachment-0001.bin>


More information about the llvm-commits mailing list