diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-04-07 17:27:48 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2011-04-07 17:27:48 +0000 |
commit | 1c0db0fd21457b437ab51cdce29b6d2ebe411eec (patch) | |
tree | 31b0c95f065941bcb4c68d5c815eae97f2758222 /llvm/lib/CodeGen/SpillPlacement.cpp | |
parent | 6d2bbc1c20fe103351df6073e67b535185f04a31 (diff) | |
download | bcm5719-llvm-1c0db0fd21457b437ab51cdce29b6d2ebe411eec.tar.gz bcm5719-llvm-1c0db0fd21457b437ab51cdce29b6d2ebe411eec.zip |
Prefer multiplications to divisions.
llvm-svn: 129080
Diffstat (limited to 'llvm/lib/CodeGen/SpillPlacement.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SpillPlacement.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SpillPlacement.cpp b/llvm/lib/CodeGen/SpillPlacement.cpp index ac7a19267c5..cab18a12406 100644 --- a/llvm/lib/CodeGen/SpillPlacement.cpp +++ b/llvm/lib/CodeGen/SpillPlacement.cpp @@ -67,11 +67,11 @@ void SpillPlacement::getAnalysisUsage(AnalysisUsage &AU) const { /// because all weights are positive. /// struct SpillPlacement::Node { - /// Frequency - Total block frequency feeding into[0] or out of[1] the bundle. + /// Scale - Inverse block frequency feeding into[0] or out of[1] the bundle. /// Ideally, these two numbers should be identical, but inaccuracies in the /// block frequency estimates means that we need to normalize ingoing and /// outgoing frequencies separately so they are commensurate. - float Frequency[2]; + float Scale[2]; /// Bias - Normalized contributions from non-transparent blocks. /// A bundle connected to a MustSpill block has a huge negative bias, @@ -107,7 +107,7 @@ struct SpillPlacement::Node { /// Node - Create a blank Node. Node() { - Frequency[0] = Frequency[1] = 0; + Scale[0] = Scale[1] = 0; } /// clear - Reset per-query data, but preserve frequencies that only depend on @@ -121,7 +121,7 @@ struct SpillPlacement::Node { /// out=0 for an ingoing link, and 1 for an outgoing link. void addLink(unsigned b, float w, bool out) { // Normalize w relative to all connected blocks from that direction. - w /= Frequency[out]; + w *= Scale[out]; // There can be multiple links to the same bundle, add them up. for (LinkVector::iterator I = Links.begin(), E = Links.end(); I != E; ++I) @@ -137,7 +137,7 @@ struct SpillPlacement::Node { /// 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]; + w *= Scale[out]; int Before = Bias > 0; Bias += w; int After = Bias > 0; @@ -185,10 +185,16 @@ bool SpillPlacement::runOnMachineFunction(MachineFunction &mf) { loops->getLoopDepth(I)); unsigned Num = I->getNumber(); BlockFrequency[Num] = Freq; - nodes[bundles->getBundle(Num, 1)].Frequency[0] += Freq; - nodes[bundles->getBundle(Num, 0)].Frequency[1] += Freq; + nodes[bundles->getBundle(Num, 1)].Scale[0] += Freq; + nodes[bundles->getBundle(Num, 0)].Scale[1] += Freq; } + // Scales are reciprocal frequencies. + for (unsigned i = 0, e = bundles->getNumBundles(); i != e; ++i) + for (unsigned d = 0; d != 2; ++d) + if (nodes[i].Scale[d] > 0) + nodes[i].Scale[d] = 1 / nodes[i].Scale[d]; + // We never change the function. return false; } |