mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-20 03:23:01 +02:00
Use a new VRegPHIUseCount to compute uses of PHI values by other phi values
in the basic block being processed. This fixes PhiElimination on kimwitu++ from taking 105s to taking a much more reasonable 0.6s (in a debug build). llvm-svn: 13453
This commit is contained in:
parent
8b57a31ff4
commit
3fb5488b5e
@ -68,12 +68,21 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
|
|||||||
const TargetInstrInfo &MII = MF.getTarget().getInstrInfo();
|
const TargetInstrInfo &MII = MF.getTarget().getInstrInfo();
|
||||||
const MRegisterInfo *RegInfo = MF.getTarget().getRegisterInfo();
|
const MRegisterInfo *RegInfo = MF.getTarget().getRegisterInfo();
|
||||||
|
|
||||||
|
// VRegPHIUseCount - Keep track of the number of times each virtual register
|
||||||
|
// is used by PHI nodes in this block.
|
||||||
|
std::map<unsigned, unsigned> VRegPHIUseCount;
|
||||||
|
|
||||||
// Get an iterator to the first instruction after the last PHI node (this may
|
// Get an iterator to the first instruction after the last PHI node (this may
|
||||||
// allso be the end of the basic block).
|
// allso be the end of the basic block). While we are scanning the PHIs,
|
||||||
|
// populate the VRegPHIUseCount map.
|
||||||
MachineBasicBlock::iterator AfterPHIsIt = MBB.begin();
|
MachineBasicBlock::iterator AfterPHIsIt = MBB.begin();
|
||||||
while (AfterPHIsIt != MBB.end() &&
|
while (AfterPHIsIt != MBB.end() &&
|
||||||
AfterPHIsIt->getOpcode() == TargetInstrInfo::PHI)
|
AfterPHIsIt->getOpcode() == TargetInstrInfo::PHI) {
|
||||||
|
MachineInstr *PHI = AfterPHIsIt;
|
||||||
|
for (unsigned i = 1, e = PHI->getNumOperands(); i < e; i += 2)
|
||||||
|
VRegPHIUseCount[PHI->getOperand(i).getReg()]++;
|
||||||
++AfterPHIsIt; // Skip over all of the PHI nodes...
|
++AfterPHIsIt; // Skip over all of the PHI nodes...
|
||||||
|
}
|
||||||
|
|
||||||
while (MBB.front().getOpcode() == TargetInstrInfo::PHI) {
|
while (MBB.front().getOpcode() == TargetInstrInfo::PHI) {
|
||||||
// Unlink the PHI node from the basic block... but don't delete the PHI yet
|
// Unlink the PHI node from the basic block... but don't delete the PHI yet
|
||||||
@ -134,6 +143,11 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adjust the VRegPHIUseCount map to account for the removal of this PHI
|
||||||
|
// node.
|
||||||
|
for (unsigned i = 1; i != MI->getNumOperands(); i += 2)
|
||||||
|
VRegPHIUseCount[MI->getOperand(i).getReg()]--;
|
||||||
|
|
||||||
// Now loop over all of the incoming arguments, changing them to copy into
|
// Now loop over all of the incoming arguments, changing them to copy into
|
||||||
// the IncomingReg register in the corresponding predecessor basic block.
|
// the IncomingReg register in the corresponding predecessor basic block.
|
||||||
//
|
//
|
||||||
@ -217,18 +231,11 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Is it used by any PHI instructions in this block?
|
// Is it used by any PHI instructions in this block?
|
||||||
if (ValueIsLive) break;
|
if (!ValueIsLive) {
|
||||||
|
std::map<unsigned,unsigned>::iterator I =
|
||||||
// Loop over all of the PHIs in this successor, checking to see if
|
VRegPHIUseCount.find(SrcReg);
|
||||||
// the register is being used...
|
ValueIsLive = I != VRegPHIUseCount.end() && I->second;
|
||||||
for (MachineBasicBlock::iterator BBI = MBB->begin(), E=MBB->end();
|
}
|
||||||
BBI != E && BBI->getOpcode() == TargetInstrInfo::PHI;
|
|
||||||
++BBI)
|
|
||||||
for (unsigned i = 1, e = BBI->getNumOperands(); i < e; i += 2)
|
|
||||||
if (BBI->getOperand(i).getReg() == SrcReg) {
|
|
||||||
ValueIsLive = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Okay, if we now know that the value is not live out of the block,
|
// Okay, if we now know that the value is not live out of the block,
|
||||||
|
Loading…
Reference in New Issue
Block a user