mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-17 18:24:34 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84673 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -292,6 +292,9 @@ bool Loop::isLoopSimplifyForm() const {
|
|||||||
// Normal-form loops have a single backedge.
|
// Normal-form loops have a single backedge.
|
||||||
if (!getLoopLatch())
|
if (!getLoopLatch())
|
||||||
return false;
|
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
|
// Each predecessor of each exit block of a normal loop is contained
|
||||||
// within the loop.
|
// within the loop.
|
||||||
SmallVector<BasicBlock *, 4> ExitBlocks;
|
SmallVector<BasicBlock *, 4> ExitBlocks;
|
||||||
@@ -299,7 +302,7 @@ bool Loop::isLoopSimplifyForm() const {
|
|||||||
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
|
for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
|
||||||
for (pred_iterator PI = pred_begin(ExitBlocks[i]),
|
for (pred_iterator PI = pred_begin(ExitBlocks[i]),
|
||||||
PE = pred_end(ExitBlocks[i]); PI != PE; ++PI)
|
PE = pred_end(ExitBlocks[i]); PI != PE; ++PI)
|
||||||
if (!contains(*PI))
|
if (!LoopBBs.count(*PI))
|
||||||
return false;
|
return false;
|
||||||
// All the requirements are met.
|
// All the requirements are met.
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user