[llvm-commits] [llvm] r54369 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Owen Anderson resistor at mac.com
Tue Aug 5 13:51:26 PDT 2008


Author: resistor
Date: Tue Aug  5 15:51:26 2008
New Revision: 54369

URL: http://llvm.org/viewvc/llvm-project?rev=54369&view=rev
Log:
We don't need to update live intervals for dead PHIs.

Modified:
    llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=54369&r1=54368&r2=54369&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Tue Aug  5 15:51:26 2008
@@ -884,38 +884,41 @@
        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);





More information about the llvm-commits mailing list