[llvm-commits] [llvm] r122811 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Cameron Zwarich
zwarich at apple.com
Tue Jan 4 08:24:51 PST 2011
Author: zwarich
Date: Tue Jan 4 10:24:51 2011
New Revision: 122811
URL: http://llvm.org/viewvc/llvm-project?rev=122811&view=rev
Log:
Switch to path halving from path compression for a small speedup. This also
makes getLeader() nonrecursive.
Modified:
llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=122811&r1=122810&r2=122811&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
+++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Tue Jan 4 10:24:51 2011
@@ -400,12 +400,18 @@
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) {
More information about the llvm-commits
mailing list