[PATCH] D100847: [RISCV] Further fixes for RVV stack offset computation

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 20 05:31:34 PDT 2021


frasercrmck created this revision.
frasercrmck added reviewers: HsiangKai, craig.topper, khchen, StephenFan, rogfer01, evandro.
Herald added subscribers: vkmr, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
frasercrmck requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

This patch fixes a case missed out by D100574 <https://reviews.llvm.org/D100574>, in which RVV scalable
stack offset computations may require three live registers in the case
where the offset's fixed component is 12 bits or larger and has a
scalable component.

Instead of adding an additional emergency spill slot, this patch further
optimizes the scalable stack offset computation sequences to reduce
register usage.

By emitting the sequence to compute the scalable component before the
fixed component, we can free up one scratch register to be reallocated
by the sequence for the fixed component. Doing this saves one register
and thus one additional emergency spill slot.

Compare:

  $x5 = LUI 1
  $x1 = ADDIW killed $x5, -1896
  $x1 = ADD $x2, killed $x1
  $x5 = PseudoReadVLENB
  $x6 = ADDI $x0, 50
  $x5 = MUL killed $x5, killed $x6
  $x1 = ADD killed $x1, killed $x5

versus:

  $x5 = PseudoReadVLENB
  $x1 = ADDI $x0, 50
  $x5 = MUL killed $x5, killed $x1
  $x1 = LUI 1
  $x1 = ADDIW killed $x1, -1896
  $x1 = ADD $x2, killed $x1
  $x1 = ADD killed $x1, killed $x5


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100847

Files:
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/test/CodeGen/RISCV/rvv/addi-scalable-offset.mir
  llvm/test/CodeGen/RISCV/rvv/emergency-slot.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100847.338837.patch
Type: text/x-patch
Size: 8029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210420/2f68b098/attachment.bin>


More information about the llvm-commits mailing list