diff options
Diffstat (limited to 'src/passes/CoalesceLocals.cpp')
-rw-r--r-- | src/passes/CoalesceLocals.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/passes/CoalesceLocals.cpp b/src/passes/CoalesceLocals.cpp index a085b61fb..af13419d3 100644 --- a/src/passes/CoalesceLocals.cpp +++ b/src/passes/CoalesceLocals.cpp @@ -70,8 +70,9 @@ struct CoalesceLocals std::vector<bool> interferences; void interfere(Index i, Index j) { - if (i == j) + if (i == j) { return; + } interferences[std::min(i, j) * numLocals + std::max(i, j)] = 1; } @@ -112,10 +113,11 @@ void CoalesceLocals::increaseBackEdgePriorities() { auto& in = loopTop->in; for (Index i = 1; i < in.size(); i++) { auto* arrivingBlock = in[i]; - if (arrivingBlock->out.size() > 1) + if (arrivingBlock->out.size() > 1) { // we just want unconditional branches to the loop top, true phi // fragments continue; + } for (auto& action : arrivingBlock->contents.actions) { if (action.isSet()) { auto* set = (*action.origin)->cast<SetLocal>(); @@ -134,8 +136,9 @@ void CoalesceLocals::calculateInterferences() { interferences.resize(numLocals * numLocals); std::fill(interferences.begin(), interferences.end(), false); for (auto& curr : basicBlocks) { - if (liveBlocks.count(curr.get()) == 0) + if (liveBlocks.count(curr.get()) == 0) { continue; // ignore dead blocks + } // everything coming in might interfere, as it might come from a different // block auto live = curr->contents.end; @@ -306,8 +309,9 @@ std::vector<Index> adjustOrderByPriorities(std::vector<Index>& baseline, } void CoalesceLocals::pickIndices(std::vector<Index>& indices) { - if (numLocals == 0) + if (numLocals == 0) { return; + } if (numLocals == 1) { indices.push_back(0); return; @@ -420,8 +424,9 @@ void CoalesceLocalsWithLearning::pickIndices(std::vector<Index>& indices) { double getFitness() { return fitness; } void dump(std::string text) { std::cout << text + ": ( "; - for (Index i = 0; i < size(); i++) + for (Index i = 0; i < size(); i++) { std::cout << (*this)[i] << " "; + } std::cout << ")\n"; std::cout << "of quality: " << getFitness() << "\n"; } @@ -445,8 +450,9 @@ void CoalesceLocalsWithLearning::pickIndices(std::vector<Index>& indices) { // secondarily, it is nice to not reorder locals unnecessarily double fragment = 1.0 / (2.0 * parent->numLocals); for (Index i = 0; i < parent->numLocals; i++) { - if ((*order)[i] == i) + if ((*order)[i] == i) { fitness += fragment; // boost for each that wasn't moved + } } // removing copies is a secondary concern fitness = (100 * fitness) + removedCopies; @@ -534,8 +540,9 @@ void CoalesceLocalsWithLearning::pickIndices(std::vector<Index>& indices) { while (1) { learner.runGeneration(); auto newBest = learner.getBest()->getFitness(); - if (newBest == oldBest) + if (newBest == oldBest) { break; // unlikely we can improve + } oldBest = newBest; #ifdef CFG_LEARN_DEBUG learner.getBest()->dump("current best"); |