summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LoopInfo.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-10-20 20:41:13 +0000
committerDan Gohman <gohman@apple.com>2009-10-20 20:41:13 +0000
commit83f5c835ff8e6d48e41af825f7e7ece6d66cea4d (patch)
tree06d055e39eead37ea4dbaf53d0103a2330dc0d1d /llvm/lib/Analysis/LoopInfo.cpp
parentc702b6ab37adde7dade82e22e59f50df33557f4f (diff)
downloadbcm5719-llvm-83f5c835ff8e6d48e41af825f7e7ece6d66cea4d.tar.gz
bcm5719-llvm-83f5c835ff8e6d48e41af825f7e7ece6d66cea4d.zip
Fix another place that calls Loop::contains a lot to construct a sorted
container of the blocks and do efficient lookups. This makes isLoopSimplifyForm much faster on large loops, fixing a significant compile-time issue in builds with assertions enabled. llvm-svn: 84673
Diffstat (limited to 'llvm/lib/Analysis/LoopInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LoopInfo.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/LoopInfo.cpp b/llvm/lib/Analysis/LoopInfo.cpp
index ce2d29f331b..e9256b74140 100644
--- a/llvm/lib/Analysis/LoopInfo.cpp
+++ b/llvm/lib/Analysis/LoopInfo.cpp
@@ -292,6 +292,9 @@ bool Loop::isLoopSimplifyForm() const {
// Normal-form loops have a single backedge.
if (!getLoopLatch())
return false;
+ // Sort the blocks vector so that we can use binary search to do quick
+ // lookups.
+ SmallPtrSet<BasicBlock *, 16> LoopBBs(block_begin(), block_end());
// Each predecessor of each exit block of a normal loop is contained
// within the loop.
SmallVector<BasicBlock *, 4> ExitBlocks;
@@ -299,7 +302,7 @@ bool Loop::isLoopSimplifyForm() const {
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
for (pred_iterator PI = pred_begin(ExitBlocks[i]),
PE = pred_end(ExitBlocks[i]); PI != PE; ++PI)
- if (!contains(*PI))
+ if (!LoopBBs.count(*PI))
return false;
// All the requirements are met.
return true;
OpenPOWER on IntegriCloud