[PATCH] D33562: MachineLICM: Add new condition for hoisting of caller preserved registers

Lei Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 25 13:08:12 PDT 2017


lei created this revision.

On PPC, global variable access is done through the table of contents (TOC) which is always in register X2. The ABI reserves this register in any functions that have calls or access global variables. Furthermore, a call through a function pointer involves saving, changing and restoring the register around the call.

Currently MachineLICM is not able to hoist instructions used to get the TOC-based addresses out of a loop if there is a virtual function call within that loop. This is because X2 is (visibly) saved/restored by the caller around the call. MachineLICM sees the use of the X2 register but since it is NOT a constant physical register in this machine function, it deemed it unsafe and does not hoist it out of the loop. Of course, overriding isConstantPhysicalRegister() for X2 is not valid since there are visible defs of the register.

What is needed is a way to communicate to MachineLICM that even though the register isn't constant in the function, it is preserved between uses - i.e. ensure that any clobber of X2 will be followed by a restore before the next use. This patch adds such a query to the MachineRegisterInfo/TargetRegisterInfo.

SPEC perf run showed negligible differences in speedups.


https://reviews.llvm.org/D33562

Files:
  include/llvm/CodeGen/MachineRegisterInfo.h
  include/llvm/Target/TargetRegisterInfo.h
  lib/CodeGen/MachineLICM.cpp
  lib/CodeGen/MachineRegisterInfo.cpp
  lib/Target/PowerPC/PPCRegisterInfo.cpp
  lib/Target/PowerPC/PPCRegisterInfo.h
  test/CodeGen/PowerPC/licm-tocReg.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33562.100283.patch
Type: text/x-patch
Size: 6585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170525/3aeedd62/attachment.bin>


More information about the llvm-commits mailing list