Instcombine PHI's of the form %PN = phi PN, X into X and
[oota-llvm.git] / lib / Transforms / Scalar / LICM.cpp
index 9f3c75705afa99c53e60dfb1e3ede527542e8a47..1cb899bf6e2bc41910e5fbfd2eca0bcd05275058 100644 (file)
@@ -39,7 +39,7 @@ namespace {
     // This transformation requires natural loop information...
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.preservesCFG();
-      AU.addRequired(LoopInfo::ID); 
+      AU.addRequired<LoopInfo>();
     }
 
   private:
@@ -84,15 +84,14 @@ namespace {
     // the specified instruction types are hoisted.
     //
     friend class InstVisitor<LICM>;
-    void visitUnaryOperator(Instruction &I) {
-      if (isLoopInvariant(I.getOperand(0))) hoist(I);
-    }
     void visitBinaryOperator(Instruction &I) {
       if (isLoopInvariant(I.getOperand(0)) && isLoopInvariant(I.getOperand(1)))
         hoist(I);
     }
-
-    void visitCastInst(CastInst &I) { visitUnaryOperator((Instruction&)I); }
+    void visitCastInst(CastInst &CI) {
+      Instruction &I = (Instruction&)CI;
+      if (isLoopInvariant(I.getOperand(0))) hoist(I);
+    }
     void visitShiftInst(ShiftInst &I) { visitBinaryOperator((Instruction&)I); }
 
     void visitGetElementPtrInst(GetElementPtrInst &GEPI) {