We don't need to update live intervals for dead PHIs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54369 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2008-08-05 20:51:26 +00:00
parent d3eda89f4c
commit e7b8205e6e

View File

@ -884,38 +884,41 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
I != E; ) { I != E; ) {
MachineInstr* PInstr = *(I++); MachineInstr* PInstr = *(I++);
// Trim live intervals of input registers. They are no longer live into // Don't do live interval updating for dead PHIs.
// this block. if (!PInstr->registerDefIsDead(PInstr->getOperand(0).getReg())) {
for (unsigned i = 1; i < PInstr->getNumOperands(); i += 2) { // Trim live intervals of input registers. They are no longer live into
unsigned reg = PInstr->getOperand(i).getReg(); // this block.
MachineBasicBlock* MBB = PInstr->getOperand(i+1).getMBB(); for (unsigned i = 1; i < PInstr->getNumOperands(); i += 2) {
LiveInterval& InputI = LI.getInterval(reg); unsigned reg = PInstr->getOperand(i).getReg();
if (MBB != PInstr->getParent() && MachineBasicBlock* MBB = PInstr->getOperand(i+1).getMBB();
InputI.liveAt(LI.getMBBStartIdx(PInstr->getParent()))) LiveInterval& InputI = LI.getInterval(reg);
InputI.removeRange(LI.getMBBStartIdx(PInstr->getParent()), if (MBB != PInstr->getParent() &&
LI.getInstructionIndex(PInstr), InputI.liveAt(LI.getMBBStartIdx(PInstr->getParent())))
true); InputI.removeRange(LI.getMBBStartIdx(PInstr->getParent()),
} LI.getInstructionIndex(PInstr),
true);
// If this is a dead PHI node, then remove it from LiveIntervals. }
unsigned DestReg = PInstr->getOperand(0).getReg();
LiveInterval& PI = LI.getInterval(DestReg); // If this is a dead PHI node, then remove it from LiveIntervals.
if (PInstr->registerDefIsDead(DestReg)) { unsigned DestReg = PInstr->getOperand(0).getReg();
if (PI.containsOneValue()) { LiveInterval& PI = LI.getInterval(DestReg);
LI.removeInterval(DestReg); if (PInstr->registerDefIsDead(DestReg)) {
} else { if (PI.containsOneValue()) {
unsigned idx = LI.getDefIndex(LI.getInstructionIndex(PInstr)); LI.removeInterval(DestReg);
PI.removeRange(*PI.getLiveRangeContaining(idx), true); } else {
unsigned idx = LI.getDefIndex(LI.getInstructionIndex(PInstr));
PI.removeRange(*PI.getLiveRangeContaining(idx), true);
}
} else {
// If the PHI is not dead, then the valno defined by the PHI
// now has an unknown def.
unsigned idx = LI.getDefIndex(LI.getInstructionIndex(PInstr));
const LiveRange* PLR = PI.getLiveRangeContaining(idx);
PLR->valno->def = ~0U;
LiveRange R (LI.getMBBStartIdx(PInstr->getParent()),
PLR->start, PLR->valno);
PI.addRange(R);
} }
} else {
// If the PHI is not dead, then the valno defined by the PHI
// now has an unknown def.
unsigned idx = LI.getDefIndex(LI.getInstructionIndex(PInstr));
const LiveRange* PLR = PI.getLiveRangeContaining(idx);
PLR->valno->def = ~0U;
LiveRange R (LI.getMBBStartIdx(PInstr->getParent()),
PLR->start, PLR->valno);
PI.addRange(R);
} }
LI.RemoveMachineInstrFromMaps(PInstr); LI.RemoveMachineInstrFromMaps(PInstr);