Use SCEVExpander::InsertCastOfTo instead of our own code. This reduces
authorChris Lattner <sabre@nondot.org>
Sat, 4 Feb 2006 09:52:43 +0000 (09:52 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 4 Feb 2006 09:52:43 +0000 (09:52 +0000)
#LLVM LOC, and auto-cse's cast instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25974 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index 49d0c58a644d409ab3eb95f85994a2d9d0f17e78..45a79d7f037fd8e2015a831120934185f6ec760c 100644 (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;
 }