diff options
author | Owen Anderson <resistor@mac.com> | 2008-08-05 20:51:26 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-08-05 20:51:26 +0000 |
commit | e7b8205e6ec63502c6375077faf0887ddf776ba0 (patch) | |
tree | bb62789a20964ec444aa9b4d9d9f3fb446bf0815 /lib/CodeGen | |
parent | d3eda89f4ceb43ff24b160f37313ab5e7dfc2e2f (diff) | |
download | external_llvm-e7b8205e6ec63502c6375077faf0887ddf776ba0.zip external_llvm-e7b8205e6ec63502c6375077faf0887ddf776ba0.tar.gz external_llvm-e7b8205e6ec63502c6375077faf0887ddf776ba0.tar.bz2 |
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/StrongPHIElimination.cpp | 61 |
1 files changed, 32 insertions, 29 deletions
diff --git a/lib/CodeGen/StrongPHIElimination.cpp b/lib/CodeGen/StrongPHIElimination.cpp index b04a879..fb625fd 100644 --- a/lib/CodeGen/StrongPHIElimination.cpp +++ b/lib/CodeGen/StrongPHIElimination.cpp @@ -884,38 +884,41 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) { I != E; ) { MachineInstr* PInstr = *(I++); - // Trim live intervals of input registers. They are no longer live into - // this block. - for (unsigned i = 1; i < PInstr->getNumOperands(); i += 2) { - unsigned reg = PInstr->getOperand(i).getReg(); - MachineBasicBlock* MBB = PInstr->getOperand(i+1).getMBB(); - LiveInterval& InputI = LI.getInterval(reg); - if (MBB != PInstr->getParent() && - InputI.liveAt(LI.getMBBStartIdx(PInstr->getParent()))) - 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 (PInstr->registerDefIsDead(DestReg)) { - if (PI.containsOneValue()) { - LI.removeInterval(DestReg); + // Don't do live interval updating for dead PHIs. + if (!PInstr->registerDefIsDead(PInstr->getOperand(0).getReg())) { + // Trim live intervals of input registers. They are no longer live into + // this block. + for (unsigned i = 1; i < PInstr->getNumOperands(); i += 2) { + unsigned reg = PInstr->getOperand(i).getReg(); + MachineBasicBlock* MBB = PInstr->getOperand(i+1).getMBB(); + LiveInterval& InputI = LI.getInterval(reg); + if (MBB != PInstr->getParent() && + InputI.liveAt(LI.getMBBStartIdx(PInstr->getParent()))) + 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 (PInstr->registerDefIsDead(DestReg)) { + if (PI.containsOneValue()) { + LI.removeInterval(DestReg); + } 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)); - PI.removeRange(*PI.getLiveRangeContaining(idx), true); + 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); |