summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LoopSimplify.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-02-11 02:13:17 +0000
committerChris Lattner <sabre@nondot.org>2006-02-11 02:13:17 +0000
commit8587eb3a51117b630c18236cc53eb865e76faf2d (patch)
tree149fb71bd39c23a070d320076f8178d5a090e5fd /lib/Transforms/Utils/LoopSimplify.cpp
parent2486af1b53615288e7b884cbb7501d7b957c3af7 (diff)
downloadllvm-8587eb3a51117b630c18236cc53eb865e76faf2d.tar.gz
llvm-8587eb3a51117b630c18236cc53eb865e76faf2d.tar.bz2
llvm-8587eb3a51117b630c18236cc53eb865e76faf2d.tar.xz
Make this check stricter. Disallow loop exit blocks from being shared by
loops and their subloops. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26118 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index 540940e4ae..c76e501af8 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -109,7 +109,6 @@ bool LoopSimplify::runOnFunction(Function &F) {
return Changed;
}
-
/// ProcessLoop - Walk the loop structure in depth first order, ensuring that
/// all loops have preheaders.
///
@@ -162,12 +161,15 @@ bool LoopSimplify::ProcessLoop(Loop *L) {
L->getExitBlocks(ExitBlocks);
SetVector<BasicBlock*> ExitBlockSet(ExitBlocks.begin(), ExitBlocks.end());
+ LoopInfo &LI = getAnalysis<LoopInfo>();
for (SetVector<BasicBlock*>::iterator I = ExitBlockSet.begin(),
E = ExitBlockSet.end(); I != E; ++I) {
BasicBlock *ExitBlock = *I;
for (pred_iterator PI = pred_begin(ExitBlock), PE = pred_end(ExitBlock);
PI != PE; ++PI)
- if (!L->contains(*PI)) {
+ // Must be exactly this loop: no subloops, parent loops, or non-loop preds
+ // allowed.
+ if (LI.getLoopFor(*PI) != L) {
RewriteLoopExitBlock(L, ExitBlock);
NumInserted++;
Changed = true;
@@ -178,6 +180,7 @@ bool LoopSimplify::ProcessLoop(Loop *L) {
// If the header has more than two predecessors at this point (from the
// preheader and from multiple backedges), we must adjust the loop.
if (L->getNumBackEdges() != 1) {
+
// If this is really a nested loop, rip it out into a child loop.
if (Loop *NL = SeparateNestedLoop(L)) {
++NumNested;
@@ -310,8 +313,8 @@ void LoopSimplify::InsertPreheaderForLoop(Loop *L) {
std::vector<BasicBlock*> OutsideBlocks;
for (pred_iterator PI = pred_begin(Header), PE = pred_end(Header);
PI != PE; ++PI)
- if (!L->contains(*PI)) // Coming in from outside the loop?
- OutsideBlocks.push_back(*PI); // Keep track of it...
+ if (!L->contains(*PI)) // Coming in from outside the loop?
+ OutsideBlocks.push_back(*PI); // Keep track of it...
// Split out the loop pre-header
BasicBlock *NewBB =