Preserve ScalarEvolution in the loop unroller.
authorDan Gohman <gohman@apple.com>
Mon, 26 Jul 2010 18:02:06 +0000 (18:02 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 26 Jul 2010 18:02:06 +0000 (18:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109412 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/LoopUnroll.cpp

index e0e07e7bbc821939d4688730e9ad6d81ee65918c..236bbe9057bfcfabe727a1d4a83d8c7cfc0428dd 100644 (file)
@@ -24,6 +24,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/LoopPass.h"
+#include "llvm/Analysis/ScalarEvolution.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -127,6 +128,11 @@ bool llvm::UnrollLoop(Loop *L, unsigned Count, LoopInfo* LI, LPPassManager* LPM)
     return false;
   }
 
+  // Notify ScalarEvolution that the loop will be substantially changed,
+  // if not outright eliminated.
+  if (ScalarEvolution *SE = LPM->getAnalysisIfAvailable<ScalarEvolution>())
+    SE->forgetLoop(L);
+
   // Find trip count
   unsigned TripCount = L->getSmallConstantTripCount();
   // Find trip multiple if count is not available