[llvm-commits] CVS: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp InstructionCombining.cpp LoopSimplify.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Jan 28 16:39:21 PST 2005



Changes in directory llvm/lib/Transforms/Scalar:

DeadStoreElimination.cpp updated: 1.10 -> 1.11
InstructionCombining.cpp updated: 1.311 -> 1.312
LoopSimplify.cpp updated: 1.52 -> 1.53
---
Log message:

Adjust to changes in instruction interfaces.


---
Diffs of the changes:  (+11 -10)

 DeadStoreElimination.cpp |   11 +++++------
 InstructionCombining.cpp |    4 ++--
 LoopSimplify.cpp         |    6 ++++--
 3 files changed, 11 insertions(+), 10 deletions(-)


Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
diff -u llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.10 llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.11
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp:1.10	Sat Jan  8 13:42:22 2005
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp	Fri Jan 28 18:39:08 2005
@@ -156,13 +156,12 @@
   // See if this made any operands dead.  We do it this way in case the
   // instruction uses the same operand twice.  We don't want to delete a
   // value then reference it.
-  while (unsigned NumOps = I->getNumOperands()) {
-    Instruction *Op = dyn_cast<Instruction>(I->getOperand(NumOps-1));
-    I->op_erase(I->op_end()-1);         // Drop from the operand list.
-    
-    if (Op) DeadInsts.insert(Op);       // Attempt to nuke it later.
+  for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
+    if (Instruction *Op = dyn_cast<Instruction>(I->getOperand(i)))
+      DeadInsts.insert(Op);      // Attempt to nuke it later.
+    I->setOperand(i, 0);         // Drop from the operand list.
   }
   
-  I->getParent()->getInstList().erase(I);
+  I->eraseFromParent();
   ++NumOther;
 }


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.311 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.312
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.311	Fri Jan 28 13:32:01 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Fri Jan 28 18:39:08 2005
@@ -575,7 +575,7 @@
   // Okay, we can do the transformation: create the new PHI node.
   PHINode *NewPN = new PHINode(I.getType(), I.getName());
   I.setName("");
-  NewPN->op_reserve(PN->getNumOperands());
+  NewPN->reserveOperandSpace(PN->getNumOperands()/2);
   InsertNewInstBefore(NewPN, *PN);
 
   // Next, add all of the operands to the PHI.
@@ -4142,7 +4142,7 @@
   // correct type, and PHI together all of the LHS's of the instructions.
   PHINode *NewPN = new PHINode(FirstInst->getOperand(0)->getType(),
                                PN.getName()+".in");
-  NewPN->op_reserve(PN.getNumOperands());
+  NewPN->reserveOperandSpace(PN.getNumOperands()/2);
 
   Value *InVal = FirstInst->getOperand(0);
   NewPN->addIncoming(InVal, PN.getIncomingBlock(0));


Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.52 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.53
--- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.52	Sun Oct 17 16:22:29 2004
+++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp	Fri Jan 28 18:39:08 2005
@@ -575,7 +575,7 @@
     PHINode *PN = cast<PHINode>(I);
     PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".be",
                                  BETerminator);
-    NewPN->op_reserve(2*BackedgeBlocks.size());
+    NewPN->reserveOperandSpace(BackedgeBlocks.size());
 
     // Loop over the PHI node, moving all entries except the one for the
     // preheader over to the new PHI node.
@@ -604,7 +604,9 @@
       PN->setIncomingValue(0, PN->getIncomingValue(PreheaderIdx));
       PN->setIncomingBlock(0, PN->getIncomingBlock(PreheaderIdx));
     }
-    PN->op_erase(PN->op_begin()+2, PN->op_end());
+    // Nuke all entries except the zero'th.
+    for (unsigned i = 0, e = PN->getNumIncomingValues()-1; i != e; ++i)
+      PN->removeIncomingValue(e-i, false);
 
     // Finally, add the newly constructed PHI node as the entry for the BEBlock.
     PN->addIncoming(NewPN, BEBlock);






More information about the llvm-commits mailing list