[PATCH] D158460: [RISCV] Reduce LMUL for vector extracts

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 14:52:31 PDT 2023


reames created this revision.
reames added reviewers: craig.topper, luke, asb, kito-cheng.
Herald added subscribers: jobnoorman, sunshaoce, VincentWu, vkmr, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, niosHD, sabuasal, bollu, simoncook, johnrusso, rbar, hiraditya, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: wangpc, eopXD, MaskRay.
Herald added a project: LLVM.

If we have a known (or bounded) index which definitely fits in a smaller LMUL register group size, we can reduce the LMUL of the slide and extract instructions.  This loosens constraints on register allocation, and allows the hardware to do less work, at the potential cost of some additional VTYPE toggles.  In practice, we appear (after prior patches) to do a decent job of eliminating the additional VTYPE toggles in most cases.

A couple of side notes:

1. I stopped at m1 here.  For machines with a DLEN < VLEN, we should probably be doing mf2, but we need to make that change a bit more globally as well.
2. Arguably, we should be narrowing the LMUL of *most* operations which are provably don't care in their input and outputs.  We've got a few selected cases, but maybe it's time to generalize something more general?  (Definitely future work!)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158460

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/rvv/extractelt-fp.ll
  llvm/test/CodeGen/RISCV/rvv/extractelt-int-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/extractelt-int-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-extract.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fp2i-sat.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-insert.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-scatter.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-reduction-int.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-strided-vpload.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-unaligned.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vpload.ll
  llvm/test/CodeGen/RISCV/rvv/vfmv.f.s.ll
  llvm/test/CodeGen/RISCV/srem-seteq-illegal-types.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158460.552140.patch
Type: text/x-patch
Size: 169421 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230821/44370af4/attachment-0001.bin>


More information about the llvm-commits mailing list