diff options
author | Dan Gohman <gohman@apple.com> | 2008-05-23 21:05:58 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-05-23 21:05:58 +0000 |
commit | 02dea8b39f3acad5de1df36273444d149145e7fc (patch) | |
tree | 48b58ec848bf21e5f417c3137fca41214104a929 /lib/Transforms/Scalar/LICM.cpp | |
parent | ee335e35acf20d1ed5b781546d647c19b608890e (diff) |
Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places to
use it instead of duplicating its functionality.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51499 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LICM.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LICM.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index e227713d4e..d9d5f0f75c 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -472,8 +472,7 @@ void LICM::sink(Instruction &I) { // nodes in it. I.removeFromParent(); - BasicBlock::iterator InsertPt = ExitBlocks[0]->begin(); - while (isa<PHINode>(InsertPt)) ++InsertPt; + BasicBlock::iterator InsertPt = ExitBlocks[0]->getFirstNonPHI(); ExitBlocks[0]->getInstList().insert(InsertPt, &I); } } else if (ExitBlocks.empty()) { @@ -542,8 +541,7 @@ void LICM::sink(Instruction &I) { // If we haven't already processed this exit block, do so now. if (InsertedBlocks.insert(ExitBlock).second) { // Insert the code after the last PHI node... - BasicBlock::iterator InsertPt = ExitBlock->begin(); - while (isa<PHINode>(InsertPt)) ++InsertPt; + BasicBlock::iterator InsertPt = ExitBlock->getFirstNonPHI(); // If this is the first exit block processed, just move the original // instruction, otherwise clone the original instruction and insert @@ -735,9 +733,7 @@ void LICM::PromoteValuesInLoop() { continue; // Copy all of the allocas into their memory locations. - BasicBlock::iterator BI = ExitBlocks[i]->begin(); - while (isa<PHINode>(*BI)) - ++BI; // Skip over all of the phi nodes in the block. + BasicBlock::iterator BI = ExitBlocks[i]->getFirstNonPHI(); Instruction *InsertPos = BI; unsigned PVN = 0; for (unsigned i = 0, e = PromotedValues.size(); i != e; ++i) { |