diff options
author | Dan Gohman <gohman@apple.com> | 2010-03-09 01:53:33 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-03-09 01:53:33 +0000 |
commit | 93452cebda66ae7e1e9d746c697da8cc0dbe9801 (patch) | |
tree | 8f7825f991b5478c1acbdec5b430b542bf7a6ea5 /llvm/lib/Analysis/LoopInfo.cpp | |
parent | a552246b3ddf6db6a0a7f538bee16a1fc0a63b41 (diff) | |
download | bcm5719-llvm-93452cebda66ae7e1e9d746c697da8cc0dbe9801.tar.gz bcm5719-llvm-93452cebda66ae7e1e9d746c697da8cc0dbe9801.zip |
Make isLCSSA ignore uses in blocks not reachable from the entry block,
as LCSSA no longer transforms such uses.
llvm-svn: 98033
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopInfo.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp index 453af5a5555..2139c29cc1f 100644 --- a/llvm/lib/Analysis/LoopInfo.cpp +++ b/llvm/lib/Analysis/LoopInfo.cpp @@ -264,6 +264,13 @@ unsigned Loop::getSmallConstantTripMultiple() const { /// isLCSSAForm - Return true if the Loop is in LCSSA form bool Loop::isLCSSAForm() const { + // Collect all the reachable blocks in the function, for fast lookups. + SmallPtrSet<BasicBlock *, 32> ReachableBBs; + BasicBlock *EntryBB = getHeader()->getParent()->begin(); + for (df_iterator<BasicBlock *> NI = df_begin(EntryBB), + NE = df_end(EntryBB); NI != NE; ++NI) + ReachableBBs.insert(*NI); + // Sort the blocks vector so that we can use binary search to do quick // lookups. SmallPtrSet<BasicBlock *, 16> LoopBBs(block_begin(), block_end()); @@ -277,9 +284,13 @@ bool Loop::isLCSSAForm() const { if (PHINode *P = dyn_cast<PHINode>(*UI)) UserBB = P->getIncomingBlock(UI); - // Check the current block, as a fast-path. Most values are used in - // the same block they are defined in. - if (UserBB != BB && !LoopBBs.count(UserBB)) + // Check the current block, as a fast-path, before checking whether + // the use is anywhere in the loop. Most values are used in the same + // block they are defined in. Also, blocks not reachable from the + // entry are special; uses in them don't need to go through PHIs. + if (UserBB != BB && + !LoopBBs.count(UserBB) && + ReachableBBs.count(UserBB)) return false; } } |