rename a function to indicate that it checks for profitability as well
[oota-llvm.git] / lib / Transforms / Scalar / LoopIndexSplit.cpp
index f625c13d453b53a7996bd6d614c4bfce3b7d7c36..6311e171e0d8900d385f638cd0585398897a8f26 100644 (file)
@@ -44,7 +44,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/IntrinsicInst.h"
 #include "llvm/Analysis/LoopPass.h"
-#include "llvm/Analysis/ScalarEvolutionExpander.h"
+#include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "llvm/Transforms/Utils/Cloning.h"
@@ -70,7 +70,6 @@ namespace {
     bool runOnLoop(Loop *L, LPPassManager &LPM);
 
     void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.addRequired<ScalarEvolution>();
       AU.addPreserved<ScalarEvolution>();
       AU.addRequiredID(LCSSAID);
       AU.addPreservedID(LCSSAID);
@@ -174,7 +173,6 @@ namespace {
     Loop *L;
     LPPassManager *LPM;
     LoopInfo *LI;
-    ScalarEvolution *SE;
     DominatorTree *DT;
     DominanceFrontier *DF;
 
@@ -205,7 +203,6 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
   if (!L->getSubLoops().empty())
     return false;
 
-  SE = &getAnalysis<ScalarEvolution>();
   DT = &getAnalysis<DominatorTree>();
   LI = &getAnalysis<LoopInfo>();
   DF = &getAnalysis<DominanceFrontier>();
@@ -236,15 +233,14 @@ bool LoopIndexSplit::runOnLoop(Loop *IncomingLoop, LPPassManager &LPM_Ref) {
     }
 
   // Reject loop if loop exit condition is not suitable.
-  SmallVector<BasicBlock *, 2> EBs;
-  L->getExitingBlocks(EBs);
-  if (EBs.size() != 1)
+  BasicBlock *ExitingBlock = L->getExitingBlock();
+  if (!ExitingBlock)
     return false;
-  BranchInst *EBR = dyn_cast<BranchInst>(EBs[0]->getTerminator());
+  BranchInst *EBR = dyn_cast<BranchInst>(ExitingBlock->getTerminator());
   if (!EBR) return false;
   ExitCondition = dyn_cast<ICmpInst>(EBR->getCondition());
   if (!ExitCondition) return false;
-  if (EBs[0] != L->getLoopLatch()) return false;
+  if (ExitingBlock != L->getLoopLatch()) return false;
   IVExitValue = ExitCondition->getOperand(1);
   if (!L->isLoopInvariant(IVExitValue))
     IVExitValue = ExitCondition->getOperand(0);