diff options
author | Mikael Holmen <mikael.holmen@ericsson.com> | 2017-09-28 08:22:35 +0000 |
---|---|---|
committer | Mikael Holmen <mikael.holmen@ericsson.com> | 2017-09-28 08:22:35 +0000 |
commit | 07f1e2e2b3880bfc3e470bb111c31028371ab8f3 (patch) | |
tree | 3c2633465bfcbe846dac6d51859846b058fbd915 | |
parent | a59e654e028fafa658246b499a35b2baaac28dfb (diff) | |
download | llvm-07f1e2e2b3880bfc3e470bb111c31028371ab8f3.zip llvm-07f1e2e2b3880bfc3e470bb111c31028371ab8f3.tar.gz llvm-07f1e2e2b3880bfc3e470bb111c31028371ab8f3.tar.bz2 |
[RegAllocGreedy]: Allow recoloring of done register if it's non-tied
Summary:
If we have a non-allocated register, we allow us to try recoloring of an
already allocated and "Done" register, even if they are of the same
register class, if the non-allocated register has at least one tied def
and the allocated one has none.
It should be easier to recolor the non-tied register than the tied one, so
it might be an improvement even if they use the same regclasses.
Reviewers: qcolombet
Reviewed By: qcolombet
Subscribers: llvm-commits, MatzeB
Differential Revision: https://reviews.llvm.org/D38309
llvm-svn: 314388
-rw-r--r-- | llvm/lib/CodeGen/RegAllocGreedy.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index 1761a72..5bef247 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -2054,6 +2054,15 @@ unsigned RAGreedy::trySplit(LiveInterval &VirtReg, AllocationOrder &Order, // Last Chance Recoloring //===----------------------------------------------------------------------===// +/// Return true if \p reg has any tied def operand. +static bool hasTiedDef(MachineRegisterInfo *MRI, unsigned reg) { + for (const MachineOperand &MO : MRI->def_operands(reg)) + if (MO.isTied()) + return true; + + return false; +} + /// mayRecolorAllInterferences - Check if the virtual registers that /// interfere with \p VirtReg on \p PhysReg (or one of its aliases) may be /// recolored to free \p PhysReg. @@ -2082,8 +2091,11 @@ RAGreedy::mayRecolorAllInterferences(unsigned PhysReg, LiveInterval &VirtReg, LiveInterval *Intf = Q.interferingVRegs()[i - 1]; // If Intf is done and sit on the same register class as VirtReg, // it would not be recolorable as it is in the same state as VirtReg. - if ((getStage(*Intf) == RS_Done && - MRI->getRegClass(Intf->reg) == CurRC) || + // However, if VirtReg has tied defs and Intf doesn't, then + // there is still a point in examining if it can be recolorable. + if (((getStage(*Intf) == RS_Done && + MRI->getRegClass(Intf->reg) == CurRC) && + !(hasTiedDef(MRI, VirtReg.reg) && !hasTiedDef(MRI, Intf->reg))) || FixedRegisters.count(Intf->reg)) { DEBUG(dbgs() << "Early abort: the interference is not recolorable.\n"); return false; |