[PATCH] D138941: [RISCV][TTI] Account for constant materialization cost when costing airthmetic operations

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 12:28:04 PST 2022


reames created this revision.
reames added reviewers: frasercrmck, asb, craig.topper, jacquesguan, kito-cheng.
Herald added subscribers: sunshaoce, VincentWu, 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, 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.

At the IR level, we generally assume that constants are free to materialize.  However, for RISCV due to some quirks of the ISA, materializing arbitrary constants can be rather expensive.  We frequently fallback to constant pool loads.

We've been slowly moving in the direction of modeling the cost of the remat as part of the instruction cost.  This has the effect of disincentivizing vectorization - mostly SLP - when we'd have to materialize an expensive constant.

We need better modeling of which constants are expensive and not, but the moment let's be consistent with how we model arithmetic and memory instructions.  The difference between the two is that arithmetic can sometimes fold a splat operation which stores can not.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138941

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
  llvm/test/Analysis/CostModel/RISCV/arith-int.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138941.478677.patch
Type: text/x-patch
Size: 8695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221129/d2e9d67e/attachment.bin>


More information about the llvm-commits mailing list