aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index 1d110e1..7687827 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -17,6 +17,7 @@
#include "llvm/Function.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/ScalarEvolutionExpander.h"
+#include "llvm/Analysis/Dominators.h"
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/Statistic.h"
@@ -43,6 +44,8 @@ namespace {
AU.addPreserved<LoopInfo>();
AU.addRequiredID(LoopSimplifyID);
AU.addPreservedID(LoopSimplifyID);
+ AU.addPreserved<DominatorTree>();
+ AU.addPreserved<DominanceFrontier>();
}
private:
@@ -314,6 +317,20 @@ bool LoopIndexSplit::processOneIterationLoop(SplitInfo &SD, LPPassManager &LPM)
}
LPM.deleteLoopFromQueue(L);
+
+ // Update Dominator Info.
+ // Only CFG change done is to remove Latch to Header edge. This
+ // does not change dominator tree because Latch did not dominate
+ // Header.
+ if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>()) {
+ DominanceFrontier::iterator HeaderDF = DF->find(Header);
+ if (HeaderDF != DF->end())
+ DF->removeFromFrontier(HeaderDF, Header);
+
+ DominanceFrontier::iterator LatchDF = DF->find(Latch);
+ if (LatchDF != DF->end())
+ DF->removeFromFrontier(LatchDF, Header);
+ }
return true;
}