[PATCH] D127541: [RISCV] Add cost model for scalable scatter and gather

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 10 14:35:40 PDT 2022


reames created this revision.
reames added reviewers: craig.topper, kito-cheng, frasercrmck.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, evandro, 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, asb, hiraditya, arichardson, mcrosier.
Herald added a project: All.
reames requested review of this revision.
Herald added subscribers: alextsao1999, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

The costing we use for fixed length vector gather and scatter is to simply count up the memory ops, and multiply by a fixed memory op cost.  For scalable vectors, we don't actually know how many lanes are active.  Instead, we have to end up making a worst case assumption on how many lanes could be active.  In the generic +V case, this results in very high costs, but we can do better when we know an upper bound on the VLEN.

There's some obvious ways to improve this - e.g. using information about VL and mask bits from the instruction to reduce the upper bound - but this seems like a reasonable starting point.

The resulting costs do bias us pretty strongly away from generating scatter/gather for generic +V, but might be useful when targeting particular CPUs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127541

Files:
  llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
  llvm/test/Analysis/CostModel/RISCV/scalable-gather.ll
  llvm/test/Analysis/CostModel/RISCV/scalable-scatter.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127541.436045.patch
Type: text/x-patch
Size: 70107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220610/a97a195e/attachment-0001.bin>


More information about the llvm-commits mailing list