diff options
author | Daniel Berlin <dberlin@dberlin.org> | 2016-08-19 22:06:23 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@dberlin.org> | 2016-08-19 22:06:23 +0000 |
commit | a36f46363f2e1205c17ff92b63412ea26ac65fb3 (patch) | |
tree | 1ad5a2c2ba2a3ff29fc4a7ead86c3787336ec401 /llvm/lib/Transforms | |
parent | 0fb33f96901e4fffb18c0b9064fa8314b1eb609b (diff) | |
download | bcm5719-llvm-a36f46363f2e1205c17ff92b63412ea26ac65fb3.tar.gz bcm5719-llvm-a36f46363f2e1205c17ff92b63412ea26ac65fb3.zip |
Convert some depth first traversals to depth_first
llvm-svn: 279331
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/NaryReassociate.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp | 6 |
3 files changed, 10 insertions, 17 deletions
diff --git a/llvm/lib/Transforms/Scalar/NaryReassociate.cpp b/llvm/lib/Transforms/Scalar/NaryReassociate.cpp index 5bde45f1779..e2081f7bb8f 100644 --- a/llvm/lib/Transforms/Scalar/NaryReassociate.cpp +++ b/llvm/lib/Transforms/Scalar/NaryReassociate.cpp @@ -207,11 +207,11 @@ static bool isPotentiallyNaryReassociable(Instruction *I) { bool NaryReassociatePass::doOneIteration(Function &F) { bool Changed = false; SeenExprs.clear(); - // Process the basic blocks in pre-order of the dominator tree. This order - // ensures that all bases of a candidate are in Candidates when we process it. - for (auto Node = GraphTraits<DominatorTree *>::nodes_begin(DT); - Node != GraphTraits<DominatorTree *>::nodes_end(DT); ++Node) { - BasicBlock *BB = (*Node)->getBlock(); + // Process the basic blocks in a depth first traversal of the dominator + // tree. This order ensures that all bases of a candidate are in Candidates + // when we process it. + for (const auto Node : depth_first(DT)) { + BasicBlock *BB = Node->getBlock(); for (auto I = BB->begin(); I != BB->end(); ++I) { if (SE->isSCEVable(I->getType()) && isPotentiallyNaryReassociable(&*I)) { const SCEV *OldSCEV = SE->getSCEV(&*I); diff --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp index e0180fb8a03..961a3c1c19c 100644 --- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp +++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp @@ -1150,14 +1150,9 @@ bool SeparateConstOffsetFromGEP::reuniteExts(Instruction *I) { bool SeparateConstOffsetFromGEP::reuniteExts(Function &F) { bool Changed = false; DominatingExprs.clear(); - for (auto Node = GraphTraits<DominatorTree *>::nodes_begin(DT); - Node != GraphTraits<DominatorTree *>::nodes_end(DT); ++Node) { - BasicBlock *BB = (*Node)->getBlock(); - for (auto I = BB->begin(); I != BB->end(); ) { - Instruction *Cur = &*I++; - Changed |= reuniteExts(Cur); - } - } + for (const auto Node : depth_first(DT)) + for (auto &I : *(Node->getBlock())) + Changed |= reuniteExts(&I); return Changed; } diff --git a/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp index a4da5fe2335..a914517e7fe 100644 --- a/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp @@ -674,11 +674,9 @@ bool StraightLineStrengthReduce::runOnFunction(Function &F) { SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE(); // Traverse the dominator tree in the depth-first order. This order makes sure // all bases of a candidate are in Candidates when we process it. - for (auto node = GraphTraits<DominatorTree *>::nodes_begin(DT); - node != GraphTraits<DominatorTree *>::nodes_end(DT); ++node) { - for (auto &I : *(*node)->getBlock()) + for (const auto Node : depth_first(DT)) + for (auto &I : *(Node->getBlock())) allocateCandidatesAndFindBasis(&I); - } // Rewrite candidates in the reverse depth-first order. This order makes sure // a candidate being rewritten is not a basis for any other candidate. |