diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-04-06 19:14:00 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-04-06 19:14:00 +0000 |
commit | 6895b87dfebbc1432cd771a8270e2c95158cca32 (patch) | |
tree | 99e9a8c93022c83896a0796ad445df19d23e77fb /llvm/lib/CodeGen/SpillPlacement.cpp | |
parent | 36b5d8a6986e8dbdaa965f44af91b45eeb81f760 (diff) | |
download | bcm5719-llvm-6895b87dfebbc1432cd771a8270e2c95158cca32.tar.gz bcm5719-llvm-6895b87dfebbc1432cd771a8270e2c95158cca32.zip |
Keep track of the number of positively biased nodes when adding constraints.
If there are no positive nodes, the algorithm can be aborted early.
llvm-svn: 129021
Diffstat (limited to 'llvm/lib/CodeGen/SpillPlacement.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SpillPlacement.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SpillPlacement.cpp b/llvm/lib/CodeGen/SpillPlacement.cpp index d648d5a9e15..0ccb93f871d 100644 --- a/llvm/lib/CodeGen/SpillPlacement.cpp +++ b/llvm/lib/CodeGen/SpillPlacement.cpp @@ -134,10 +134,14 @@ struct SpillPlacement::Node { } /// addBias - Bias this node from an ingoing[0] or outgoing[1] link. - void addBias(float w, bool out) { + /// Return the change to the total number of positive biases. + int addBias(float w, bool out) { // Normalize w relative to all connected blocks from that direction. w /= Frequency[out]; + int Before = Bias > 0; Bias += w; + int After = Bias > 0; + return After - Before; } /// update - Recompute Value from Bias and Links. Return true when node @@ -237,14 +241,14 @@ void SpillPlacement::addConstraints(ArrayRef<BlockConstraint> LiveBlocks) { if (I->Entry != DontCare) { unsigned ib = bundles->getBundle(I->Number, 0); activate(ib); - nodes[ib].addBias(Freq * Bias[I->Entry], 1); + PositiveNodes += nodes[ib].addBias(Freq * Bias[I->Entry], 1); } // Live-out from block? if (I->Exit != DontCare) { unsigned ob = bundles->getBundle(I->Number, 1); activate(ob); - nodes[ob].addBias(Freq * Bias[I->Exit], 0); + PositiveNodes += nodes[ob].addBias(Freq * Bias[I->Exit], 0); } } } @@ -292,6 +296,7 @@ void SpillPlacement::prepare(BitVector &RegBundles) { ActiveNodes = &RegBundles; ActiveNodes->clear(); ActiveNodes->resize(bundles->getNumBundles()); + PositiveNodes = 0; } bool |