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

Owen Anderson resistor at mac.com
Tue Aug 5 14:18:52 PDT 2008


Author: resistor
Date: Tue Aug  5 16:18:51 2008
New Revision: 54371

URL: http://llvm.org/viewvc/llvm-project?rev=54371&view=rev
Log:
Oops, we were already checking for dead phis.  Handle this the proper way, then.

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=54371&r1=54370&r2=54371&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Tue Aug  5 16:18:51 2008
@@ -884,8 +884,17 @@
        I != E; ) {
     MachineInstr* PInstr = *(I++);
     
-    // Don't do live interval updating for dead PHIs.
-    if (!PInstr->registerDefIsDead(PInstr->getOperand(0).getReg())) {
+    // 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 {
       // Trim live intervals of input registers.  They are no longer live into
       // this block.
       for (unsigned i = 1; i < PInstr->getNumOperands(); i += 2) {
@@ -899,26 +908,14 @@
                              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));
-        const LiveRange* PLR = PI.getLiveRangeContaining(idx);
-        PLR->valno->def = ~0U;
-        LiveRange R (LI.getMBBStartIdx(PInstr->getParent()),
-                    PLR->start, PLR->valno);
-        PI.addRange(R);
-      }
+      // 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