Use SCEVExpander::InsertCastOfTo instead of our own code. This reduces

#LLVM LOC, and auto-cse's cast instructions.

llvm-svn: 25974
This commit is contained in:
Chris Lattner 2006-02-04 09:52:43 +00:00
parent 151eb931ec
commit e4dc660cbb

View File

@ -176,24 +176,7 @@ Value *LoopStrengthReduce::getCastedVersionOf(Value *V) {
Value *&New = CastedPointers[V];
if (New) return New;
BasicBlock::iterator InsertPt;
if (Argument *Arg = dyn_cast<Argument>(V)) {
// Insert into the entry of the function, after any allocas.
InsertPt = Arg->getParent()->begin()->begin();
while (isa<AllocaInst>(InsertPt)) ++InsertPt;
} else {
if (InvokeInst *II = dyn_cast<InvokeInst>(V)) {
InsertPt = II->getNormalDest()->begin();
} else {
InsertPt = cast<Instruction>(V);
++InsertPt;
}
// Do not insert casts into the middle of PHI node blocks.
while (isa<PHINode>(InsertPt)) ++InsertPt;
}
New = new CastInst(V, UIntPtrTy, V->getName(), InsertPt);
New = SCEVExpander::InsertCastOfTo(V, UIntPtrTy);
DeadInsts.insert(cast<Instruction>(New));
return New;
}