From 0e8f85f87e9388179f9708e8a9898e48632f1bab Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 5 Aug 2007 00:15:57 +0000 Subject: [PATCH] Switch some std::sets to SmallPtrSet. This speeds up domtree by 10% and postdomtree by 17% llvm-svn: 40829 --- llvm/lib/Analysis/PostDominators.cpp | 6 +++--- llvm/lib/VMCore/Dominators.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Analysis/PostDominators.cpp b/llvm/lib/Analysis/PostDominators.cpp index 244f8cdff525..d2892de8ed24 100644 --- a/llvm/lib/Analysis/PostDominators.cpp +++ b/llvm/lib/Analysis/PostDominators.cpp @@ -29,7 +29,7 @@ F("postdomtree", "Post-Dominator Tree Construction", true); unsigned PostDominatorTree::DFSPass(BasicBlock *V, unsigned N) { std::vector workStack; - std::set visited; + SmallPtrSet Visited; workStack.push_back(V); do { @@ -37,7 +37,7 @@ unsigned PostDominatorTree::DFSPass(BasicBlock *V, unsigned N) { InfoRec &CurVInfo = Info[currentBB]; // Visit each block only once. - if (visited.insert(currentBB).second) { + if (Visited.insert(currentBB)) { CurVInfo.Semi = ++N; CurVInfo.Label = currentBB; @@ -55,7 +55,7 @@ unsigned PostDominatorTree::DFSPass(BasicBlock *V, unsigned N) { InfoRec &SuccVInfo = Info[*PI]; if (SuccVInfo.Semi == 0) { SuccVInfo.Parent = currentBB; - if (!visited.count(*PI)) { + if (!Visited.count(*PI)) { workStack.push_back(*PI); visitChild = true; } diff --git a/llvm/lib/VMCore/Dominators.cpp b/llvm/lib/VMCore/Dominators.cpp index 6231eb8e469d..7d0fbaa29aa5 100644 --- a/llvm/lib/VMCore/Dominators.cpp +++ b/llvm/lib/VMCore/Dominators.cpp @@ -211,7 +211,7 @@ unsigned DominatorTree::DFSPass(BasicBlock *V, unsigned N) { void DominatorTree::Compress(BasicBlock *VIn) { std::vector Work; - std::set Visited; + SmallPtrSet Visited; BasicBlock *VInAncestor = Info[VIn].Ancestor; InfoRec &VInVAInfo = Info[VInAncestor]; @@ -225,9 +225,9 @@ void DominatorTree::Compress(BasicBlock *VIn) { InfoRec &VAInfo = Info[VAncestor]; // Process Ancestor first - if (Visited.count(VAncestor) == 0 && VAInfo.Ancestor != 0) { + if (Visited.insert(VAncestor) && + VAInfo.Ancestor != 0) { Work.push_back(VAncestor); - Visited.insert(VAncestor); continue; } Work.pop_back();