[llvm] r279331 - Convert some depth first traversals to depth_first
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 15:06:24 PDT 2016
Author: dannyb
Date: Fri Aug 19 17:06:23 2016
New Revision: 279331
URL: http://llvm.org/viewvc/llvm-project?rev=279331&view=rev
Log:
Convert some depth first traversals to depth_first
Modified:
llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp
llvm/trunk/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp?rev=279331&r1=279330&r2=279331&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NaryReassociate.cpp Fri Aug 19 17:06:23 2016
@@ -207,11 +207,11 @@ static bool isPotentiallyNaryReassociabl
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);
Modified: llvm/trunk/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp?rev=279331&r1=279330&r2=279331&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp Fri Aug 19 17:06:23 2016
@@ -1150,14 +1150,9 @@ bool SeparateConstOffsetFromGEP::reunite
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;
}
Modified: llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp?rev=279331&r1=279330&r2=279331&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp Fri Aug 19 17:06:23 2016
@@ -674,11 +674,9 @@ bool StraightLineStrengthReduce::runOnFu
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.
More information about the llvm-commits
mailing list