[PATCH] D66576: [Regalloc][WIP] Increase CSR cost in RegAllocGreedy to favour splitting/spill over CSR first use

Zixuan Wu (Zeson) via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 01:13:53 PDT 2019


wuzish created this revision.
wuzish added reviewers: qcolombet, wmi, nemanjai, hfinkel, MatzeB, jsji, dexonsmith.
Herald added subscribers: llvm-commits, MaskRay, hiraditya.
Herald added a project: LLVM.

It's trying to solve the issue which was proposed at D32201 <https://reviews.llvm.org/D32201> and D27366 <https://reviews.llvm.org/D27366> before.

I refine the adjusting CSR cost to enhance the RegAllocGreedy to favour splitting/spill the virtual register which is being allocated instead of allocate CSR directly. If use CSR, we need add load/store pair in prologue/epilogue. So if the cost caused by spillings which is introduced by trying to avoid using CSR is larger than load/store pair in prologue/epilogue, we would choose to use CSR. I make the raw cost is 2 because load and store are 2 spilling memory operation, the cost calculation is similar to SpillPlacer. Then we need scale the cost relative to entry frequency.

It can help to expand the opportunity exposed to shrink-wrapping at later phase because it causes the use of CSR is delayed to the BB with the call instead of entry BB.

It's trying to avoid the magic cost number for different target. The CSRCost is a relative times corresponding to the num of load/store operation in prologue/epilogue.


Repository:
  rL LLVM

https://reviews.llvm.org/D66576

Files:
  llvm/include/llvm/CodeGen/TargetRegisterInfo.h
  llvm/lib/CodeGen/RegAllocGreedy.cpp
  llvm/test/CodeGen/PowerPC/csr-split.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66576.216555.patch
Type: text/x-patch
Size: 12154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190822/b3ca669c/attachment.bin>


More information about the llvm-commits mailing list