[PATCH] D46182: [RISCV] Set isReMaterializable on ADDI and LUI instructions

Alex Bradbury via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 27 05:21:57 PDT 2018


asb created this revision.
asb added reviewers: apazos, mgrang, sabuasal, shiva0217.
Herald added subscribers: edward-jones, zzheng, kito-cheng, niosHD, jordy.potman.lists, simoncook, johnrusso, rbar.

Although this patch is straight-forward, I'm hoping that more eyes on it will help point out if there are any additional hooks I may be missing related to rematerialisation.

The isReMaterlizable flag is somewhat confusing, unlike most other instruction flags it is currently interpreted as a hint (mightBeRematerializable would be a better name). While LUI is always rematerialisable, for an instruction like ADDI it depends on its operands. TargetInstrInfo::isTriviallyReMaterializable will call TargetInstrInfo::isReallyTriviallyReMaterializable, which in turn calls TargetInstrInfo::isReallyTriviallyReMaterializableGeneric. We rely on the logic in the latter to pick out instances of ADDI that really are rematerializable.

The isReMaterializable flag does make a difference on a variety of test programs. The recently committed remat.ll test case demonstrates how stack usage is reduce and a unnecessary lw/sw can be removed. Stack usage in the Proc0 function in dhrystone reduces from 192 bytes to 112 bytes.

For the sake of completeness, this patch also implements RISCVRegisterInfo::isConstantPhysReg. Although this is called from a number of places, it doesn't seem to result in different codegen for any programs I've thrown at it. However, it is called in the rematerialisation codepath and it seems sensible to implement something correct here.

@apazos, @mgrang, @sabuasal: could you please check the workloads you reported before indicated spilling of trivial values to ensure this patch addresses those.


Repository:
  rL LLVM

https://reviews.llvm.org/D46182

Files:
  lib/Target/RISCV/RISCVInstrInfo.td
  lib/Target/RISCV/RISCVRegisterInfo.cpp
  lib/Target/RISCV/RISCVRegisterInfo.h
  test/CodeGen/RISCV/remat.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46182.144314.patch
Type: text/x-patch
Size: 5790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180427/9292b5f0/attachment.bin>


More information about the llvm-commits mailing list