From a7908ae369307f91da200b4324c0c6a39cbafb14 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 26 Jul 2010 18:02:06 +0000 Subject: [PATCH] Preserve ScalarEvolution in the loop unroller. llvm-svn: 109412 --- llvm/lib/Transforms/Utils/LoopUnroll.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/llvm/lib/Transforms/Utils/LoopUnroll.cpp b/llvm/lib/Transforms/Utils/LoopUnroll.cpp index e0e07e7bbc82..236bbe9057bf 100644 --- a/llvm/lib/Transforms/Utils/LoopUnroll.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnroll.cpp @@ -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()) + SE->forgetLoop(L); + // Find trip count unsigned TripCount = L->getSmallConstantTripCount(); // Find trip multiple if count is not available