Adjust to changes in instruction interfaces.

llvm-svn: 19900
This commit is contained in:
Chris Lattner 2005-01-29 00:39:08 +00:00
parent a3f06fa2dd
commit d8e20188c6
3 changed files with 11 additions and 10 deletions

View File

@ -156,13 +156,12 @@ void DSE::DeleteDeadInstructionChains(Instruction *I,
// See if this made any operands dead. We do it this way in case the // 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 // instruction uses the same operand twice. We don't want to delete a
// value then reference it. // value then reference it.
while (unsigned NumOps = I->getNumOperands()) { for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
Instruction *Op = dyn_cast<Instruction>(I->getOperand(NumOps-1)); if (Instruction *Op = dyn_cast<Instruction>(I->getOperand(i)))
I->op_erase(I->op_end()-1); // Drop from the operand list. DeadInsts.insert(Op); // Attempt to nuke it later.
I->setOperand(i, 0); // Drop from the operand list.
if (Op) DeadInsts.insert(Op); // Attempt to nuke it later.
} }
I->getParent()->getInstList().erase(I); I->eraseFromParent();
++NumOther; ++NumOther;
} }

View File

@ -575,7 +575,7 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
// Okay, we can do the transformation: create the new PHI node. // Okay, we can do the transformation: create the new PHI node.
PHINode *NewPN = new PHINode(I.getType(), I.getName()); PHINode *NewPN = new PHINode(I.getType(), I.getName());
I.setName(""); I.setName("");
NewPN->op_reserve(PN->getNumOperands()); NewPN->reserveOperandSpace(PN->getNumOperands()/2);
InsertNewInstBefore(NewPN, *PN); InsertNewInstBefore(NewPN, *PN);
// Next, add all of the operands to the PHI. // Next, add all of the operands to the PHI.
@ -4142,7 +4142,7 @@ Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) {
// correct type, and PHI together all of the LHS's of the instructions. // correct type, and PHI together all of the LHS's of the instructions.
PHINode *NewPN = new PHINode(FirstInst->getOperand(0)->getType(), PHINode *NewPN = new PHINode(FirstInst->getOperand(0)->getType(),
PN.getName()+".in"); PN.getName()+".in");
NewPN->op_reserve(PN.getNumOperands()); NewPN->reserveOperandSpace(PN.getNumOperands()/2);
Value *InVal = FirstInst->getOperand(0); Value *InVal = FirstInst->getOperand(0);
NewPN->addIncoming(InVal, PN.getIncomingBlock(0)); NewPN->addIncoming(InVal, PN.getIncomingBlock(0));

View File

@ -575,7 +575,7 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
PHINode *PN = cast<PHINode>(I); PHINode *PN = cast<PHINode>(I);
PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".be", PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".be",
BETerminator); BETerminator);
NewPN->op_reserve(2*BackedgeBlocks.size()); NewPN->reserveOperandSpace(BackedgeBlocks.size());
// Loop over the PHI node, moving all entries except the one for the // Loop over the PHI node, moving all entries except the one for the
// preheader over to the new PHI node. // preheader over to the new PHI node.
@ -604,7 +604,9 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
PN->setIncomingValue(0, PN->getIncomingValue(PreheaderIdx)); PN->setIncomingValue(0, PN->getIncomingValue(PreheaderIdx));
PN->setIncomingBlock(0, PN->getIncomingBlock(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. // Finally, add the newly constructed PHI node as the entry for the BEBlock.
PN->addIncoming(NewPN, BEBlock); PN->addIncoming(NewPN, BEBlock);