Switch to path halving from path compression for a small speedup. This also

makes getLeader() nonrecursive.

llvm-svn: 122811
This commit is contained in:
Cameron Zwarich 2011-01-04 16:24:51 +00:00
parent 4ccb923820
commit 5cd3d718f6
1 changed files with 12 additions and 6 deletions

View File

@ -400,12 +400,18 @@ void StrongPHIElimination::addReg(unsigned Reg) {
StrongPHIElimination::Node*
StrongPHIElimination::Node::getLeader() {
Node* parentPointer = parent.getPointer();
if (parentPointer == this)
return this;
Node* newParent = parentPointer->getLeader();
parent.setPointer(newParent);
return newParent;
Node* N = this;
Node* Parent = parent.getPointer();
Node* Grandparent = Parent->parent.getPointer();
while (Parent != Grandparent) {
N->parent.setPointer(Grandparent);
N = Grandparent;
Parent = Parent->parent.getPointer();
Grandparent = Parent->parent.getPointer();
}
return Parent;
}
unsigned StrongPHIElimination::getRegColor(unsigned Reg) {