Make getOrInsertCanonicalInductionVariable guarantee that its
authorDan Gohman <gohman@apple.com>
Tue, 20 Jul 2010 16:44:52 +0000 (16:44 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 20 Jul 2010 16:44:52 +0000 (16:44 +0000)
result is a PHINode*.

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

include/llvm/Analysis/ScalarEvolutionExpander.h
lib/Analysis/ScalarEvolutionExpander.cpp

index 9501555aacf17dc60f53fedb7a477c7a28ab94ad..e4f2809fd51950e50a0c03f802c0f2dabd68e129 100644 (file)
@@ -76,7 +76,8 @@ namespace llvm {
     /// canonical induction variable of the specified type for the specified
     /// loop (inserting one if there is none).  A canonical induction variable
     /// starts at zero and steps by one on each iteration.
-    Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty);
+    PHINode *getOrInsertCanonicalInductionVariable(const Loop *L,
+                                                   const Type *Ty);
 
     /// expandCodeFor - Insert code to directly compute the specified SCEV
     /// expression into the program.  The inserted code is inserted into the
index 0f3e33fe53197dcea525c4b024b7704e20528bbf..6017c51fc634c2f695dd41aa4ac743b90113a288 100644 (file)
@@ -1349,7 +1349,7 @@ void SCEVExpander::restoreInsertPoint(BasicBlock *BB, BasicBlock::iterator I) {
 /// canonical induction variable of the specified type for the specified
 /// loop (inserting one if there is none).  A canonical induction variable
 /// starts at zero and steps by one on each iteration.
-Value *
+PHINode *
 SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L,
                                                     const Type *Ty) {
   assert(Ty->isIntegerTy() && "Can only insert integer induction variables!");
@@ -1357,7 +1357,7 @@ SCEVExpander::getOrInsertCanonicalInductionVariable(const Loop *L,
                                    SE.getConstant(Ty, 1), L);
   BasicBlock *SaveInsertBB = Builder.GetInsertBlock();
   BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint();
-  Value *V = expandCodeFor(H, 0, L->getHeader()->begin());
+  PHINode *V = cast<PHINode>(expandCodeFor(H, 0, L->getHeader()->begin()));
   if (SaveInsertBB)
     restoreInsertPoint(SaveInsertBB, SaveInsertPt);
   return V;