Check A dominates B and vise versa first while searching for nearest

common dominator.

llvm-svn: 37559
This commit is contained in:
Devang Patel 2007-06-12 17:17:57 +00:00
parent 2150cde0e4
commit dcf0c03ff7
1 changed files with 4 additions and 8 deletions

View File

@ -387,12 +387,12 @@ BasicBlock *DominatorTreeBase::findNearestCommonDominator(BasicBlock *A,
DomTreeNode *NodeB = getNode(B);
// If B immediately dominates A then B is nearest common dominator.
if (NodeA->getIDom() == NodeB)
// If B dominates A then B is nearest common dominator.
if (dominates(B,A))
return B;
// If A immediately dominates B then A is nearest common dominator.
if (NodeB->getIDom() == NodeA)
// If A dominates B then A is nearest common dominator.
if (dominates(A,B))
return A;
// Collect NodeA dominators set.
@ -404,10 +404,6 @@ BasicBlock *DominatorTreeBase::findNearestCommonDominator(BasicBlock *A,
IDomA = IDomA->getIDom();
}
// If B dominates A then B is nearest common dominator.
if (NodeADoms.count(NodeB) != 0)
return B;
// Walk NodeB immediate dominators chain and find common dominator node.
DomTreeNode *IDomB = NodeB->getIDom();
while(IDomB) {