HomePhabricator

[TwoAddressInstructionPass] Improve the SrcRegMap and DstRegMap computation

Authored by Carrot on Oct 11 2021, 3:28 PM.

Description

[TwoAddressInstructionPass] Improve the SrcRegMap and DstRegMap computation

This patch contains following enhancements to SrcRegMap and DstRegMap:

1 In findOnlyInterestingUse not only check if the Reg is two address usage,
  but also check after commutation can it be two address usage.

2 If a physical register is clobbered, remove SrcRegMap entries that are
  mapped to it.

3 In processTiedPairs, when create a new COPY instruction, add a SrcRegMap
  entry only when the COPY instruction is coalescable. (The COPY src is
  killed)

With these enhancements isProfitableToCommute can do better commute decision,
and finally more register copies are removed.

Differential Revision: https://reviews.llvm.org/D108731