Add a new Operator class, for handling Instructions and ConstantExprs
[oota-llvm.git] / lib / Transforms / Scalar / LoopUnroll.cpp
index 386b91c252cac50997663449e29bc7a81a35fe49..23757cdb2d29c3326bbe02fa3ebbdb7c6a34bbb3 100644 (file)
@@ -42,7 +42,7 @@ namespace {
   class VISIBILITY_HIDDEN LoopUnroll : public LoopPass {
   public:
     static char ID; // Pass ID, replacement for typeid
-    LoopUnroll() : LoopPass((intptr_t)&ID) {}
+    LoopUnroll() : LoopPass(&ID) {}
 
     /// A magic value for use with the Threshold parameter to indicate
     /// that the loop unroll should be performed regardless of how much
@@ -73,7 +73,7 @@ namespace {
 char LoopUnroll::ID = 0;
 static RegisterPass<LoopUnroll> X("loop-unroll", "Unroll loops");
 
-LoopPass *llvm::createLoopUnrollPass() { return new LoopUnroll(); }
+Pass *llvm::createLoopUnrollPass() { return new LoopUnroll(); }
 
 /// ApproximateLoopSize - Approximate the size of the loop.
 static unsigned ApproximateLoopSize(const Loop *L) {
@@ -89,6 +89,8 @@ static unsigned ApproximateLoopSize(const Loop *L) {
         // Ignore instructions only used by the loop terminator.
       } else if (isa<DbgInfoIntrinsic>(I)) {
         // Ignore debug instructions
+      } else if (isa<GetElementPtrInst>(I) && I->hasOneUse()) {
+        // Ignore GEP as they generally are subsumed into a load or store.
       } else if (isa<CallInst>(I)) {
         // Estimate size overhead introduced by call instructions which
         // is higher than other instructions. Here 3 and 10 are magic
@@ -170,10 +172,10 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) {
     return false;
 
   // FIXME: Reconstruct dom info, because it is not preserved properly.
-  DominatorTree *DT = getAnalysisToUpdate<DominatorTree>();
+  DominatorTree *DT = getAnalysisIfAvailable<DominatorTree>();
   if (DT) {
     DT->runOnFunction(*F);
-    DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>();
+    DominanceFrontier *DF = getAnalysisIfAvailable<DominanceFrontier>();
     if (DF)
       DF->runOnFunction(*F);
   }