Add cannonicalization of shl X, 1 -> add X, X
[oota-llvm.git] / lib / Transforms / Scalar / PiNodeInsertion.cpp
index 2c16049684d71b26b498b78b7dbdec42fca5a51a..940b56fd29b8100b8ec3795984066f66d6e950f1 100644 (file)
@@ -40,13 +40,11 @@ static Statistic<> NumInserted("pinodes\t\t- Number of Pi nodes inserted");
 
 namespace {
   struct PiNodeInserter : public FunctionPass {
-    const char *getPassName() const { return "Pi Node Insertion"; }
-    
     virtual bool runOnFunction(Function &F);
     
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.preservesCFG();
-      AU.addRequired(DominatorSet::ID);
+      AU.addRequired<DominatorSet>();
     }
 
     // insertPiNodeFor - Insert a Pi node for V in the successors of BB if our
@@ -56,6 +54,8 @@ namespace {
     //
     bool insertPiNodeFor(Value *V, BasicBlock *BB, Value *Rep = 0);
   };
+
+  RegisterOpt<PiNodeInserter> X("pinodes", "Pi Node Insertion");
 }
 
 Pass *createPiNodeInsertionPass() { return new PiNodeInserter(); }
@@ -148,13 +148,8 @@ bool PiNodeInserter::insertPiNodeFor(Value *V, BasicBlock *Succ, Value *Rep) {
     
   // Create the Pi node...
   Value *Pi = Rep;
-  if (Rep == 0) {
-    PHINode *Phi = new PHINode(V->getType(), V->getName() + ".pi");
-    
-    // Insert the Pi node in the successor basic block...
-    Succ->getInstList().push_front(Phi);
-    Pi = Phi;
-  }
+  if (Rep == 0)      // Insert the Pi node in the successor basic block...
+    Pi = new PHINode(V->getType(), V->getName() + ".pi", Succ->begin());
     
   // Loop over all of the uses of V, replacing ones that the Pi node
   // dominates with references to the Pi node itself.