[PATCH] D127511: [RISCV] Refine costs for i1 reductions

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


reames created this revision.
reames added reviewers: craig.topper, frasercrmck, kito-cheng.
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: pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

Our actual lowering for i1 reductions uses ctpop combined with possibly a vector negate and possibly a logic op afterwards.  I believe ctpop to be low cost on all reasonable hardware.

The default costing implementation here was returning quite inconsistent costs.  and/or were returning very high costs (because we seem to think moving into scalar registers is very expensive?) and others were returning lower but still too high (because of the assumed tree reduce strategy).  While we should probably improve the generic costing strategy for i1 vectors, let's start by fixing the immediate problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127511

Files:
  llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
  llvm/test/Analysis/CostModel/RISCV/reduce-add.ll
  llvm/test/Analysis/CostModel/RISCV/reduce-and.ll
  llvm/test/Analysis/CostModel/RISCV/reduce-max.ll
  llvm/test/Analysis/CostModel/RISCV/reduce-min.ll
  llvm/test/Analysis/CostModel/RISCV/reduce-or.ll
  llvm/test/Analysis/CostModel/RISCV/reduce-xor.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127511.435950.patch
Type: text/x-patch
Size: 36199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220610/e7ed8513/attachment.bin>


More information about the llvm-commits mailing list