[PATCH] D157373: [RISCV] add a compress optimization for stack inst.

lcvon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 8 01:34:50 PDT 2023


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

For callee save/restored operation, it mostly uses the
following inst patterns:

  sw rs2, offset(x2)
  sd rs2, offset(x2)
  fsw rs2, offset(x2)
  fsd rs2, offset(x2)
  lw rd, offset(x2)
  ld rd, offset(x2)
  flw rd, offset(x2)
  fld rd, offset(x2)

and offset decides whether the instructions can be compressed.
now offset 2032 will be set by default if stacksize is larger
than 2^12-1 to save and restore callee saved register, so it
will prevent all the callee saved stack insts be compressed.

Allocate proper offset for stack insts is useful to decrease
the codesize and improve performance and add an option
riscv-compress-stack-inst to control whether to do this
optimization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157373

Files:
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/test/CodeGen/RISCV/compress-stack.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157373.548102.patch
Type: text/x-patch
Size: 8565 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230808/9badf6c6/attachment.bin>


More information about the llvm-commits mailing list