[PATCH] D150447: [MachineSink] Don't reject sinking because of a dead def in isProfitableToSinkTo()

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 06:57:31 PDT 2023


jonpa created this revision.
jonpa added reviewers: rampitec, sebastian-ne, vangthao, arsenm, uweigand.
Herald added subscribers: kerbowa, pengfei, arphaman, hiraditya, jvesely.
Herald added a project: All.
jonpa requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

I am not quite sure, but it seems that the intent in this profitability check may be to avoid sinking phys-reg uses as they would prolong live ranges.

It seems reasonable to me to sink an instruction regardless if it has a dead def of a physreg or not. Physreg defs are checked in other places and sinking is only done with dead defs of regs that are not live into the target MBB.

It may be that this has more than a negligble impact on code generation, so perhaps this was avoided purposefully. It seems to change quite a lot of files on SPEC/SystemZ, at least. On the other hand, it seems that dead defs are in fact allowed generally. Please fill me in if I am missing something here.

This came up when I was experimenting with a pseudo that has the same operands as the target instruction, except it pretends to clobber CC. At least in this case I don't see why the sinking of that instruction should be any different than without that fake dead CC def.


https://reviews.llvm.org/D150447

Files:
  llvm/lib/CodeGen/MachineSink.cpp
  llvm/test/CodeGen/AMDGPU/collapse-endcf.ll
  llvm/test/CodeGen/AMDGPU/loop_exit_with_xor.ll
  llvm/test/CodeGen/AMDGPU/should-not-hoist-set-inactive.ll
  llvm/test/CodeGen/SystemZ/machinesink-dead-cc.mir
  llvm/test/CodeGen/X86/2007-01-13-StackPtrIndex.ll
  llvm/test/CodeGen/X86/dag-update-nodetomatch.ll
  llvm/test/CodeGen/X86/statepoint-cmp-sunk-past-statepoint.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150447.521639.patch
Type: text/x-patch
Size: 12269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230512/b87dc6c9/attachment.bin>


More information about the llvm-commits mailing list