diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-18 22:14:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-18 22:14:10 +0000 |
commit | f1ab4b4eac5603d19c20f4a508f93a118a52bdd5 (patch) | |
tree | c9d06cae7fa1fa63934b7b22a2a0ea3a83eba636 /lib/Transforms/Scalar | |
parent | 7c8781e71f8f9fa6956a7de056fc8a4e5c172c86 (diff) | |
download | external_llvm-f1ab4b4eac5603d19c20f4a508f93a118a52bdd5.tar.gz external_llvm-f1ab4b4eac5603d19c20f4a508f93a118a52bdd5.tar.bz2 external_llvm-f1ab4b4eac5603d19c20f4a508f93a118a52bdd5.zip |
Change the ExitBlocks list from being explicitly contained in the Loop
structure to being dynamically computed on demand. This makes updating
loop information MUCH easier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13045 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 12 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopUnroll.cpp | 23 |
2 files changed, 9 insertions, 26 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index d5eb668107..d375dcf4a9 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -185,8 +185,10 @@ void IndVarSimplify::LinearFunctionTestReplace(Loop *L, SCEV *IterationCount, ScalarEvolutionRewriter &RW) { // Find the exit block for the loop. We can currently only handle loops with // a single exit. - if (L->getExitBlocks().size() != 1) return; - BasicBlock *ExitBlock = L->getExitBlocks()[0]; + std::vector<BasicBlock*> ExitBlocks; + L->getExitBlocks(ExitBlocks); + if (ExitBlocks.size() != 1) return; + BasicBlock *ExitBlock = ExitBlocks[0]; // Make sure there is only one predecessor block in the loop. BasicBlock *ExitingBlock = 0; @@ -269,8 +271,10 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) { // We insert the code into the preheader of the loop if the loop contains // multiple exit blocks, or in the exit block if there is exactly one. BasicBlock *BlockToInsertInto; - if (L->getExitBlocks().size() == 1) - BlockToInsertInto = L->getExitBlocks()[0]; + std::vector<BasicBlock*> ExitBlocks; + L->getExitBlocks(ExitBlocks); + if (ExitBlocks.size() == 1) + BlockToInsertInto = ExitBlocks[0]; else BlockToInsertInto = Preheader; BasicBlock::iterator InsertPt = BlockToInsertInto->begin(); diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp index 3794b81036..8cda34d109 100644 --- a/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/lib/Transforms/Scalar/LoopUnroll.cpp @@ -109,18 +109,6 @@ static inline void RemapInstruction(Instruction *I, } } -static void ChangeExitBlocksFromTo(Loop::iterator I, Loop::iterator E, - BasicBlock *Old, BasicBlock *New) { - for (; I != E; ++I) { - Loop *L = *I; - if (L->hasExitBlock(Old)) { - L->changeExitBlock(Old, New); - ChangeExitBlocksFromTo(L->begin(), L->end(), Old, New); - } - } -} - - bool LoopUnroll::visitLoop(Loop *L) { bool Changed = false; @@ -157,8 +145,7 @@ bool LoopUnroll::visitLoop(Loop *L) { } DEBUG(std::cerr << "UNROLLING!\n"); - assert(L->getExitBlocks().size() == 1 && "Must have exactly one exit block!"); - BasicBlock *LoopExit = L->getExitBlocks()[0]; + BasicBlock *LoopExit = BI->getSuccessor(L->contains(BI->getSuccessor(0))); // Create a new basic block to temporarily hold all of the cloned code. BasicBlock *NewBlock = new BasicBlock(); @@ -292,14 +279,6 @@ bool LoopUnroll::visitLoop(Loop *L) { LI->removeBlock(Preheader); LI->removeBlock(BB); - // If any loops used Preheader as an exit block, update them to use LoopExit. - if (Parent) - ChangeExitBlocksFromTo(Parent->begin(), Parent->end(), - Preheader, LoopExit); - else - ChangeExitBlocksFromTo(LI->begin(), LI->end(), - Preheader, LoopExit); - // If the preheader was the entry block of this function, move the exit block // to be the new entry of the loop. Function *F = LoopExit->getParent(); |