[llvm-commits] [llvm] r69807 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolutionExpander.h lib/Analysis/ScalarEvolutionExpander.cpp

Dan Gohman gohman at apple.com
Wed Apr 22 09:05:58 PDT 2009


Author: djg
Date: Wed Apr 22 11:05:50 2009
New Revision: 69807

URL: http://llvm.org/viewvc/llvm-project?rev=69807&view=rev
Log:
Use BasicBlock::iterator instead of Instruction* for insert points,
to better handle inserting instructions at the end of a block.

Modified:
    llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h
    llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp

Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=69807&r1=69806&r2=69807&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Wed Apr 22 11:05:50 2009
@@ -32,7 +32,7 @@
     std::map<SCEVHandle, Value*> InsertedExpressions;
     std::set<Instruction*> InsertedInstructions;
 
-    Instruction *InsertPt;
+    BasicBlock::iterator InsertPt;
 
     friend struct SCEVVisitor<SCEVExpander, Value*>;
   public:
@@ -71,12 +71,13 @@
       InsertedInstructions.insert(I);
     }
 
-    Instruction *getInsertionPoint() const { return InsertPt; }
-    
+    BasicBlock::iterator getInsertionPoint() const { return InsertPt; }
+
     /// expandCodeFor - Insert code to directly compute the specified SCEV
     /// expression into the program.  The inserted code is inserted into the
     /// specified block.
-    Value *expandCodeFor(SCEVHandle SH, const Type *Ty, Instruction *IP);
+    Value *expandCodeFor(SCEVHandle SH, const Type *Ty,
+                         BasicBlock::iterator IP);
 
     /// InsertCastOfTo - Insert a cast of V to the specified type, doing what
     /// we can to share the casts.
@@ -90,7 +91,7 @@
     /// InsertBinop - Insert the specified binary operator, doing a small amount
     /// of work to avoid inserting an obviously redundant operation.
     static Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
-                              Value *RHS, Instruction *InsertPt);
+                              Value *RHS, BasicBlock::iterator InsertPt);
 
   private:
     Value *expand(const SCEV *S);

Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=69807&r1=69806&r2=69807&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Wed Apr 22 11:05:50 2009
@@ -100,7 +100,7 @@
 /// InsertBinop - Insert the specified binary operator, doing a small amount
 /// of work to avoid inserting an obviously redundant operation.
 Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
-                                 Value *RHS, Instruction *InsertPt) {
+                                 Value *RHS, BasicBlock::iterator InsertPt) {
   // Fold a binop with constant operands.
   if (Constant *CLHS = dyn_cast<Constant>(LHS))
     if (Constant *CRHS = dyn_cast<Constant>(RHS))
@@ -244,7 +244,7 @@
     // the insert point.  Otherwise, L is a loop that is a parent of the insert
     // point loop.  If we can, move the multiply to the outer most loop that it
     // is safe to be in.
-    Instruction *MulInsertPt = InsertPt;
+    BasicBlock::iterator MulInsertPt = getInsertionPoint();
     Loop *InsertPtLoop = LI.getLoopFor(MulInsertPt->getParent());
     if (InsertPtLoop != L && InsertPtLoop &&
         L->contains(InsertPtLoop->getHeader())) {
@@ -284,21 +284,21 @@
   const Type *Ty = SE.getEffectiveSCEVType(S->getType());
   Value *V = expand(S->getOperand());
   V = InsertNoopCastOfTo(V, SE.getEffectiveSCEVType(V->getType()));
-  return CastInst::CreateTruncOrBitCast(V, Ty, "tmp.", InsertPt);
+  return new TruncInst(V, Ty, "tmp.", InsertPt);
 }
 
 Value *SCEVExpander::visitZeroExtendExpr(const SCEVZeroExtendExpr *S) {
   const Type *Ty = SE.getEffectiveSCEVType(S->getType());
   Value *V = expand(S->getOperand());
   V = InsertNoopCastOfTo(V, SE.getEffectiveSCEVType(V->getType()));
-  return CastInst::CreateZExtOrBitCast(V, Ty, "tmp.", InsertPt);
+  return new ZExtInst(V, Ty, "tmp.", InsertPt);
 }
 
 Value *SCEVExpander::visitSignExtendExpr(const SCEVSignExtendExpr *S) {
   const Type *Ty = SE.getEffectiveSCEVType(S->getType());
   Value *V = expand(S->getOperand());
   V = InsertNoopCastOfTo(V, SE.getEffectiveSCEVType(V->getType()));
-  return CastInst::CreateSExtOrBitCast(V, Ty, "tmp.", InsertPt);
+  return new SExtInst(V, Ty, "tmp.", InsertPt);
 }
 
 Value *SCEVExpander::visitSMaxExpr(const SCEVSMaxExpr *S) {
@@ -328,11 +328,11 @@
 }
 
 Value *SCEVExpander::expandCodeFor(SCEVHandle SH, const Type *Ty,
-                                   Instruction *IP) {
+                                   BasicBlock::iterator IP) {
   // Expand the code for this SCEV.
   assert(SE.getTypeSizeInBits(Ty) == SE.getTypeSizeInBits(SH->getType()) &&
          "non-trivial casts should be done with the SCEVs directly!");
-  this->InsertPt = IP;
+  InsertPt = IP;
   Value *V = expand(SH);
   return InsertNoopCastOfTo(V, Ty);
 }





More information about the llvm-commits mailing list