forked from OSchip/llvm-project
Convert some depth first traversals to depth_first
llvm-svn: 279331
This commit is contained in:
parent
0fb33f9690
commit
a36f46363f
|
@ -207,11 +207,11 @@ static bool isPotentiallyNaryReassociable(Instruction *I) {
|
||||||
bool NaryReassociatePass::doOneIteration(Function &F) {
|
bool NaryReassociatePass::doOneIteration(Function &F) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
SeenExprs.clear();
|
SeenExprs.clear();
|
||||||
// Process the basic blocks in pre-order of the dominator tree. This order
|
// Process the basic blocks in a depth first traversal of the dominator
|
||||||
// ensures that all bases of a candidate are in Candidates when we process it.
|
// tree. This order ensures that all bases of a candidate are in Candidates
|
||||||
for (auto Node = GraphTraits<DominatorTree *>::nodes_begin(DT);
|
// when we process it.
|
||||||
Node != GraphTraits<DominatorTree *>::nodes_end(DT); ++Node) {
|
for (const auto Node : depth_first(DT)) {
|
||||||
BasicBlock *BB = (*Node)->getBlock();
|
BasicBlock *BB = Node->getBlock();
|
||||||
for (auto I = BB->begin(); I != BB->end(); ++I) {
|
for (auto I = BB->begin(); I != BB->end(); ++I) {
|
||||||
if (SE->isSCEVable(I->getType()) && isPotentiallyNaryReassociable(&*I)) {
|
if (SE->isSCEVable(I->getType()) && isPotentiallyNaryReassociable(&*I)) {
|
||||||
const SCEV *OldSCEV = SE->getSCEV(&*I);
|
const SCEV *OldSCEV = SE->getSCEV(&*I);
|
||||||
|
|
|
@ -1150,14 +1150,9 @@ bool SeparateConstOffsetFromGEP::reuniteExts(Instruction *I) {
|
||||||
bool SeparateConstOffsetFromGEP::reuniteExts(Function &F) {
|
bool SeparateConstOffsetFromGEP::reuniteExts(Function &F) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
DominatingExprs.clear();
|
DominatingExprs.clear();
|
||||||
for (auto Node = GraphTraits<DominatorTree *>::nodes_begin(DT);
|
for (const auto Node : depth_first(DT))
|
||||||
Node != GraphTraits<DominatorTree *>::nodes_end(DT); ++Node) {
|
for (auto &I : *(Node->getBlock()))
|
||||||
BasicBlock *BB = (*Node)->getBlock();
|
Changed |= reuniteExts(&I);
|
||||||
for (auto I = BB->begin(); I != BB->end(); ) {
|
|
||||||
Instruction *Cur = &*I++;
|
|
||||||
Changed |= reuniteExts(Cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -674,11 +674,9 @@ bool StraightLineStrengthReduce::runOnFunction(Function &F) {
|
||||||
SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
|
SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
|
||||||
// Traverse the dominator tree in the depth-first order. This order makes sure
|
// 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.
|
// all bases of a candidate are in Candidates when we process it.
|
||||||
for (auto node = GraphTraits<DominatorTree *>::nodes_begin(DT);
|
for (const auto Node : depth_first(DT))
|
||||||
node != GraphTraits<DominatorTree *>::nodes_end(DT); ++node) {
|
for (auto &I : *(Node->getBlock()))
|
||||||
for (auto &I : *(*node)->getBlock())
|
|
||||||
allocateCandidatesAndFindBasis(&I);
|
allocateCandidatesAndFindBasis(&I);
|
||||||
}
|
|
||||||
|
|
||||||
// Rewrite candidates in the reverse depth-first order. This order makes sure
|
// Rewrite candidates in the reverse depth-first order. This order makes sure
|
||||||
// a candidate being rewritten is not a basis for any other candidate.
|
// a candidate being rewritten is not a basis for any other candidate.
|
||||||
|
|
Loading…
Reference in New Issue