When processing frame index virtual registers, consider all available registers

(if there are any) and use the one which remains available for the longest
rather than just using the first one. This should help enable better re-use
of the loaded frame index values. rdar://7318760



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107847 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jim Grosbach
2010-07-08 00:38:54 +00:00
parent 0238f8c430
commit d9642faf7c
3 changed files with 37 additions and 8 deletions

View File

@@ -885,10 +885,20 @@ void PEI::scavengeFrameVirtualRegs(MachineFunction &Fn) {
// Scavenge a new scratch register
CurrentVirtReg = Reg;
const TargetRegisterClass *RC = Fn.getRegInfo().getRegClass(Reg);
CurrentScratchReg = RS->FindUnusedReg(RC);
if (CurrentScratchReg == 0)
const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo();
BitVector Candidates(TRI->getNumRegs());
RS->getRegsAvailable(RC, Candidates);
// If there are any registers available, use the one that's
// unused for the longest after this instruction. That increases
// the ability to reuse the value.
if (Candidates.any()) {
MachineBasicBlock::iterator UMI;
CurrentScratchReg = RS->findSurvivorReg(I, Candidates, 25, UMI);
} else {
// No register is "free". Scavenge a register.
CurrentScratchReg = RS->scavengeRegister(RC, I, SPAdj);
}
PrevValue = Value;
}