diff options
author | Dan Gohman <gohman@apple.com> | 2009-07-15 01:25:43 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-07-15 01:25:43 +0000 |
commit | c43e47938aaf3890f8f62201ff65897e85239d53 (patch) | |
tree | e027487c3e7253f89a1ee7c8aae7465f46c63201 /llvm/lib/Transforms/Utils/LoopSimplify.cpp | |
parent | 7f318128d0367f4e7c38b10f33ae5ef5127aeac4 (diff) | |
download | bcm5719-llvm-c43e47938aaf3890f8f62201ff65897e85239d53.tar.gz bcm5719-llvm-c43e47938aaf3890f8f62201ff65897e85239d53.zip |
Make makeLoopInvariant report whether it made any changes or not,
and use this to simplify more code.
llvm-svn: 75722
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopSimplify.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index cfdfcb0f73a..81fa4f96c4c 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -93,7 +93,7 @@ namespace { BasicBlock *RewriteLoopExitBlock(Loop *L, BasicBlock *Exit); BasicBlock *InsertPreheaderForLoop(Loop *L); Loop *SeparateNestedLoop(Loop *L); - void InsertUniqueBackedgeBlock(Loop *L); + void InsertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader); void PlaceSplitBlockCarefully(BasicBlock *NewBB, SmallVectorImpl<BasicBlock*> &SplitPreds, Loop *L); @@ -244,7 +244,7 @@ ReprocessLoop: // If we either couldn't, or didn't want to, identify nesting of the loops, // insert a new block that all backedges target, then make it jump to the // loop header. - InsertUniqueBackedgeBlock(L); + InsertUniqueBackedgeBlock(L, Preheader); NumInserted++; Changed = true; } @@ -288,9 +288,8 @@ ReprocessLoop: Instruction *Inst = I++; if (Inst == CI) continue; - if (!L->makeLoopInvariant(Inst, Preheader->getTerminator())) { + if (!L->makeLoopInvariant(Inst, Changed, Preheader->getTerminator())) { AllInvariant = false; - Changed = true; break; } } @@ -574,11 +573,10 @@ Loop *LoopSimplify::SeparateNestedLoop(Loop *L) { /// backedges to target a new basic block and have that block branch to the loop /// header. This ensures that loops have exactly one backedge. /// -void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) { +void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L, BasicBlock *Preheader) { assert(L->getNumBackEdges() > 1 && "Must have > 1 backedge!"); // Get information about the loop - BasicBlock *Preheader = L->getLoopPreheader(); BasicBlock *Header = L->getHeader(); Function *F = Header->getParent(); |