aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopSimplify.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2020-07-20 15:00:27 +0200
committerBenjamin Kramer <benny.kra@googlemail.com>2020-07-20 15:00:59 +0200
commit44ab60f74d60102b4192bbb54b66eeac9f2d35f2 (patch)
tree08b1fff1cb165ec74a4253c046e6769c95bc435b /llvm/lib/Transforms/Utils/LoopSimplify.cpp
parent684e416ef1361fc3cc93bebbee1466b844751497 (diff)
downloadllvm-44ab60f74d60102b4192bbb54b66eeac9f2d35f2.zip
llvm-44ab60f74d60102b4192bbb54b66eeac9f2d35f2.tar.gz
llvm-44ab60f74d60102b4192bbb54b66eeac9f2d35f2.tar.bz2
[LoopSimplify] Use SmallPtrSet and range for loops more. NFCI.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopSimplify.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopSimplify.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
index a8445e9..a2e9198 100644
--- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
@@ -163,7 +163,7 @@ BasicBlock *llvm::InsertPreheaderForLoop(Loop *L, DominatorTree *DT,
/// if it's not already in there. Stop predecessor traversal when we reach
/// StopBlock.
static void addBlockAndPredsToSet(BasicBlock *InputBB, BasicBlock *StopBlock,
- std::set<BasicBlock*> &Blocks) {
+ SmallPtrSetImpl<BasicBlock *> &Blocks) {
SmallVector<BasicBlock *, 8> Worklist;
Worklist.push_back(InputBB);
do {
@@ -171,8 +171,7 @@ static void addBlockAndPredsToSet(BasicBlock *InputBB, BasicBlock *StopBlock,
if (Blocks.insert(BB).second && BB != StopBlock)
// If BB is not already processed and it is not a stop block then
// insert its predecessor in the work list
- for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) {
- BasicBlock *WBB = *I;
+ for (BasicBlock *WBB : predecessors(BB)) {
Worklist.push_back(WBB);
}
} while (!Worklist.empty());
@@ -308,9 +307,8 @@ static Loop *separateNestedLoop(Loop *L, BasicBlock *Preheader,
// Determine which blocks should stay in L and which should be moved out to
// the Outer loop now.
- std::set<BasicBlock*> BlocksInL;
- for (pred_iterator PI=pred_begin(Header), E = pred_end(Header); PI!=E; ++PI) {
- BasicBlock *P = *PI;
+ SmallPtrSet<BasicBlock *, 4> BlocksInL;
+ for (BasicBlock *P : predecessors(Header)) {
if (DT->dominates(Header, P))
addBlockAndPredsToSet(P, Header, BlocksInL);
}