Reverted back to previous revision - this was previously merged
authorJohn Criswell <criswell@uiuc.edu>
Thu, 18 Dec 2003 17:19:19 +0000 (17:19 +0000)
committerJohn Criswell <criswell@uiuc.edu>
Thu, 18 Dec 2003 17:19:19 +0000 (17:19 +0000)
according to the CVS log messages.

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

lib/Transforms/Scalar/IndVarSimplify.cpp

index 0cc408c61b7e97a209a4472c754537d5853206fe..763854ee0b111b3b2cdafddefcf6077f2e3d47c3 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Transforms/Scalar.h"
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Transforms/Scalar.h"
-#include "llvm/Analysis/InductionVariable.h"
-#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Constants.h"
+#include "llvm/Type.h"
 #include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
 #include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
-#include "llvm/Type.h"
-#include "llvm/Constants.h"
+#include "llvm/Analysis/InductionVariable.h"
+#include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/CFG.h"
+#include "llvm/Transforms/Utils/Local.h"
 #include "Support/Debug.h"
 #include "Support/Statistic.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
 #include "Support/Debug.h"
 #include "Support/Statistic.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
-
-namespace llvm {
+using namespace llvm;
 
 namespace {
   Statistic<> NumRemoved ("indvars", "Number of aux indvars removed");
 
 namespace {
   Statistic<> NumRemoved ("indvars", "Number of aux indvars removed");
@@ -141,6 +141,8 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
 
     DEBUG(IV->print(std::cerr));
 
 
     DEBUG(IV->print(std::cerr));
 
+    while (isa<PHINode>(AfterPHIIt)) ++AfterPHIIt;
+
     // Don't do math with pointers...
     const Type *IVTy = IV->Phi->getType();
     if (isa<PointerType>(IVTy)) IVTy = Type::ULongTy;
     // Don't do math with pointers...
     const Type *IVTy = IV->Phi->getType();
     if (isa<PointerType>(IVTy)) IVTy = Type::ULongTy;
@@ -186,6 +188,12 @@ static bool TransformLoop(LoopInfo *Loops, Loop *Loop) {
       IV->Phi->setName("");
       Val->setName(OldName);
 
       IV->Phi->setName("");
       Val->setName(OldName);
 
+      // Get the incoming values used by the PHI node
+      std::vector<Value*> PHIOps;
+      PHIOps.reserve(IV->Phi->getNumIncomingValues());
+      for (unsigned i = 0, e = IV->Phi->getNumIncomingValues(); i != e; ++i)
+        PHIOps.push_back(IV->Phi->getIncomingValue(i));
+
       // Delete the old, now unused, phi node...
       Header->getInstList().erase(IV->Phi);
 
       // Delete the old, now unused, phi node...
       Header->getInstList().erase(IV->Phi);
 
@@ -242,8 +250,7 @@ namespace {
                                            "Canonicalize Induction Variables");
 }
 
                                            "Canonicalize Induction Variables");
 }
 
-Pass *createIndVarSimplifyPass() {
+Pass *llvm::createIndVarSimplifyPass() {
   return new InductionVariableSimplify();
 }
 
   return new InductionVariableSimplify();
 }
 
-} // End llvm namespace