blob: f6786b30b21cc59c5973702b4ea3f8aff5342ce0 [file] [log] [blame]
Eugene Zelenko79ea5b52017-09-21 23:20:16 +00001//===- SpillPlacement.cpp - Optimal Spill Code Placement ------------------===//
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the spill code placement analysis.
11//
12// Each edge bundle corresponds to a node in a Hopfield network. Constraints on
13// basic blocks are weighted by the block frequency and added to become the node
14// bias.
15//
16// Transparent basic blocks have the variable live through, but don't care if it
17// is spilled or in a register. These blocks become connections in the Hopfield
18// network, again weighted by block frequency.
19//
20// The Hopfield network minimizes (possibly locally) its energy function:
21//
22// E = -sum_n V_n * ( B_n + sum_{n, m linked by b} V_m * F_b )
23//
24// The energy function represents the expected spill code execution frequency,
25// or the cost of spilling. This is a Lyapunov function which never increases
26// when a node is updated. It is guaranteed to converge to a local minimum.
27//
28//===----------------------------------------------------------------------===//
29
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000030#include "SpillPlacement.h"
Eugene Zelenko79ea5b52017-09-21 23:20:16 +000031#include "llvm/ADT/ArrayRef.h"
Jakub Staszakf31034d2013-03-18 23:45:45 +000032#include "llvm/ADT/BitVector.h"
Eugene Zelenko79ea5b52017-09-21 23:20:16 +000033#include "llvm/ADT/SmallVector.h"
34#include "llvm/ADT/SparseSet.h"
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000035#include "llvm/CodeGen/EdgeBundles.h"
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000036#include "llvm/CodeGen/MachineBasicBlock.h"
Benjamin Kramer4eed7562013-06-17 19:00:36 +000037#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000038#include "llvm/CodeGen/MachineFunction.h"
39#include "llvm/CodeGen/MachineLoopInfo.h"
40#include "llvm/CodeGen/Passes.h"
Eugene Zelenko79ea5b52017-09-21 23:20:16 +000041#include "llvm/Pass.h"
42#include "llvm/Support/BlockFrequency.h"
43#include <algorithm>
44#include <cassert>
45#include <cstdint>
46#include <utility>
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000047
48using namespace llvm;
49
Matthias Braun94c49042017-05-25 21:26:32 +000050#define DEBUG_TYPE "spill-code-placement"
Chandler Carruth8677f2f2014-04-22 02:02:50 +000051
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000052char SpillPlacement::ID = 0;
Eugene Zelenko79ea5b52017-09-21 23:20:16 +000053
54char &llvm::SpillPlacementID = SpillPlacement::ID;
55
Matthias Braun94c49042017-05-25 21:26:32 +000056INITIALIZE_PASS_BEGIN(SpillPlacement, DEBUG_TYPE,
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000057 "Spill Code Placement Analysis", true, true)
58INITIALIZE_PASS_DEPENDENCY(EdgeBundles)
59INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo)
Matthias Braun94c49042017-05-25 21:26:32 +000060INITIALIZE_PASS_END(SpillPlacement, DEBUG_TYPE,
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000061 "Spill Code Placement Analysis", true, true)
62
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000063void SpillPlacement::getAnalysisUsage(AnalysisUsage &AU) const {
64 AU.setPreservesAll();
Benjamin Kramer4eed7562013-06-17 19:00:36 +000065 AU.addRequired<MachineBlockFrequencyInfo>();
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000066 AU.addRequiredTransitive<EdgeBundles>();
67 AU.addRequiredTransitive<MachineLoopInfo>();
68 MachineFunctionPass::getAnalysisUsage(AU);
69}
70
71/// Node - Each edge bundle corresponds to a Hopfield node.
72///
73/// The node contains precomputed frequency data that only depends on the CFG,
74/// but Bias and Links are computed each time placeSpills is called.
75///
76/// The node Value is positive when the variable should be in a register. The
77/// value can change when linked nodes change, but convergence is very fast
78/// because all weights are positive.
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000079struct SpillPlacement::Node {
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +000080 /// BiasN - Sum of blocks that prefer a spill.
81 BlockFrequency BiasN;
Eugene Zelenko79ea5b52017-09-21 23:20:16 +000082
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +000083 /// BiasP - Sum of blocks that prefer a register.
84 BlockFrequency BiasP;
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000085
86 /// Value - Output value of this node computed from the Bias and links.
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +000087 /// This is always on of the values {-1, 0, 1}. A positive number means the
88 /// variable should go in a register through this bundle.
89 int Value;
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000090
Eugene Zelenko79ea5b52017-09-21 23:20:16 +000091 using LinkVector = SmallVector<std::pair<BlockFrequency, unsigned>, 4>;
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000092
93 /// Links - (Weight, BundleNo) for all transparent blocks connecting to other
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +000094 /// bundles. The weights are all positive block frequencies.
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +000095 LinkVector Links;
96
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +000097 /// SumLinkWeights - Cached sum of the weights of all links + ThresHold.
98 BlockFrequency SumLinkWeights;
99
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000100 /// preferReg - Return true when this node prefers to be in a register.
101 bool preferReg() const {
102 // Undecided nodes (Value==0) go on the stack.
103 return Value > 0;
104 }
105
106 /// mustSpill - Return True if this node is so biased that it must spill.
107 bool mustSpill() const {
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000108 // We must spill if Bias < -sum(weights) or the MustSpill flag was set.
109 // BiasN is saturated when MustSpill is set, make sure this still returns
110 // true when the RHS saturates. Note that SumLinkWeights includes Threshold.
111 return BiasN >= BiasP + SumLinkWeights;
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000112 }
113
114 /// clear - Reset per-query data, but preserve frequencies that only depend on
Eugene Zelenko79ea5b52017-09-21 23:20:16 +0000115 /// the CFG.
Chandler Carruthbbb28e72014-10-02 22:23:14 +0000116 void clear(const BlockFrequency &Threshold) {
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000117 BiasN = BiasP = Value = 0;
Chandler Carruthbbb28e72014-10-02 22:23:14 +0000118 SumLinkWeights = Threshold;
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000119 Links.clear();
120 }
121
122 /// addLink - Add a link to bundle b with weight w.
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000123 void addLink(unsigned b, BlockFrequency w) {
124 // Update cached sum.
125 SumLinkWeights += w;
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000126
127 // There can be multiple links to the same bundle, add them up.
128 for (LinkVector::iterator I = Links.begin(), E = Links.end(); I != E; ++I)
129 if (I->second == b) {
130 I->first += w;
131 return;
132 }
133 // This must be the first link to b.
134 Links.push_back(std::make_pair(w, b));
135 }
136
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000137 /// addBias - Bias this node.
138 void addBias(BlockFrequency freq, BorderConstraint direction) {
139 switch (direction) {
140 default:
141 break;
142 case PrefReg:
143 BiasP += freq;
144 break;
145 case PrefSpill:
146 BiasN += freq;
147 break;
148 case MustSpill:
149 BiasN = BlockFrequency::getMaxFrequency();
150 break;
151 }
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000152 }
153
154 /// update - Recompute Value from Bias and Links. Return true when node
155 /// preference changes.
Chandler Carruthbbb28e72014-10-02 22:23:14 +0000156 bool update(const Node nodes[], const BlockFrequency &Threshold) {
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000157 // Compute the weighted sum of inputs.
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000158 BlockFrequency SumN = BiasN;
159 BlockFrequency SumP = BiasP;
160 for (LinkVector::iterator I = Links.begin(), E = Links.end(); I != E; ++I) {
161 if (nodes[I->second].Value == -1)
162 SumN += I->first;
163 else if (nodes[I->second].Value == 1)
164 SumP += I->first;
165 }
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000166
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000167 // Each weighted sum is going to be less than the total frequency of the
168 // bundle. Ideally, we should simply set Value = sign(SumP - SumN), but we
169 // will add a dead zone around 0 for two reasons:
170 //
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000171 // 1. It avoids arbitrary bias when all links are 0 as is possible during
172 // initial iterations.
173 // 2. It helps tame rounding errors when the links nominally sum to 0.
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000174 //
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000175 bool Before = preferReg();
Chandler Carruthbbb28e72014-10-02 22:23:14 +0000176 if (SumN >= SumP + Threshold)
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000177 Value = -1;
Chandler Carruthbbb28e72014-10-02 22:23:14 +0000178 else if (SumP >= SumN + Threshold)
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000179 Value = 1;
180 else
181 Value = 0;
182 return Before != preferReg();
183 }
Quentin Colombeta4992162016-05-19 22:40:37 +0000184
185 void getDissentingNeighbors(SparseSet<unsigned> &List,
186 const Node nodes[]) const {
187 for (const auto &Elt : Links) {
188 unsigned n = Elt.second;
189 // Neighbors that already have the same value are not going to
190 // change because of this node changing.
191 if (Value != nodes[n].Value)
192 List.insert(n);
193 }
194 }
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000195};
196
197bool SpillPlacement::runOnMachineFunction(MachineFunction &mf) {
198 MF = &mf;
199 bundles = &getAnalysis<EdgeBundles>();
200 loops = &getAnalysis<MachineLoopInfo>();
201
202 assert(!nodes && "Leaking node array");
203 nodes = new Node[bundles->getNumBundles()];
Quentin Colombeta4992162016-05-19 22:40:37 +0000204 TodoList.clear();
205 TodoList.setUniverse(bundles->getNumBundles());
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000206
207 // Compute total ingoing and outgoing block frequencies for all bundles.
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000208 BlockFrequencies.resize(mf.getNumBlockIDs());
Michael Gottesman1a938c22013-12-14 00:25:47 +0000209 MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
Duncan P. N. Exon Smith861e4db2014-04-08 19:18:56 +0000210 setThreshold(MBFI->getEntryFreq());
Duncan P. N. Exon Smithac4d7b62015-10-09 22:56:24 +0000211 for (auto &I : mf) {
212 unsigned Num = I.getNumber();
213 BlockFrequencies[Num] = MBFI->getBlockFreq(&I);
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000214 }
215
216 // We never change the function.
217 return false;
218}
219
220void SpillPlacement::releaseMemory() {
221 delete[] nodes;
Craig Topper4ba84432014-04-14 00:51:57 +0000222 nodes = nullptr;
Quentin Colombeta4992162016-05-19 22:40:37 +0000223 TodoList.clear();
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000224}
225
226/// activate - mark node n as active if it wasn't already.
227void SpillPlacement::activate(unsigned n) {
Quentin Colombeta4992162016-05-19 22:40:37 +0000228 TodoList.insert(n);
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000229 if (ActiveNodes->test(n))
230 return;
231 ActiveNodes->set(n);
Chandler Carruthbbb28e72014-10-02 22:23:14 +0000232 nodes[n].clear(Threshold);
Jakob Stoklund Olesen1dc12aa2012-05-21 03:11:23 +0000233
234 // Very large bundles usually come from big switches, indirect branches,
235 // landing pads, or loops with many 'continue' statements. It is difficult to
236 // allocate registers when so many different blocks are involved.
237 //
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000238 // Give a small negative bias to large bundles such that a substantial
239 // fraction of the connected blocks need to be interested before we consider
240 // expanding the region through the bundle. This helps compile time by
241 // limiting the number of blocks visited and the number of links in the
242 // Hopfield network.
243 if (bundles->getBlocks(n).size() > 100) {
244 nodes[n].BiasP = 0;
Michael Gottesman523823b2013-12-14 02:37:38 +0000245 nodes[n].BiasN = (MBFI->getEntryFreq() / 16);
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000246 }
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000247}
248
Adrian Prantl26b584c2018-05-01 15:54:18 +0000249/// Set the threshold for a given entry frequency.
Chandler Carruthbbb28e72014-10-02 22:23:14 +0000250///
251/// Set the threshold relative to \c Entry. Since the threshold is used as a
252/// bound on the open interval (-Threshold;Threshold), 1 is the minimum
253/// threshold.
254void SpillPlacement::setThreshold(const BlockFrequency &Entry) {
255 // Apparently 2 is a good threshold when Entry==2^14, but we need to scale
256 // it. Divide by 2^13, rounding as appropriate.
257 uint64_t Freq = Entry.getFrequency();
258 uint64_t Scaled = (Freq >> 13) + bool(Freq & (1 << 12));
259 Threshold = std::max(UINT64_C(1), Scaled);
260}
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000261
Jakob Stoklund Olesen9efa2a22011-04-06 19:13:57 +0000262/// addConstraints - Compute node biases and weights from a set of constraints.
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000263/// Set a bit in NodeMask for each active node.
Jakob Stoklund Olesen9efa2a22011-04-06 19:13:57 +0000264void SpillPlacement::addConstraints(ArrayRef<BlockConstraint> LiveBlocks) {
265 for (ArrayRef<BlockConstraint>::iterator I = LiveBlocks.begin(),
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000266 E = LiveBlocks.end(); I != E; ++I) {
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000267 BlockFrequency Freq = BlockFrequencies[I->Number];
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000268
269 // Live-in to block?
270 if (I->Entry != DontCare) {
Eugene Zelenko79ea5b52017-09-21 23:20:16 +0000271 unsigned ib = bundles->getBundle(I->Number, false);
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000272 activate(ib);
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000273 nodes[ib].addBias(Freq, I->Entry);
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000274 }
275
276 // Live-out from block?
277 if (I->Exit != DontCare) {
Eugene Zelenko79ea5b52017-09-21 23:20:16 +0000278 unsigned ob = bundles->getBundle(I->Number, true);
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000279 activate(ob);
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000280 nodes[ob].addBias(Freq, I->Exit);
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000281 }
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000282 }
283}
284
Jakob Stoklund Olesene60f1032011-07-23 03:10:19 +0000285/// addPrefSpill - Same as addConstraints(PrefSpill)
Jakob Stoklund Olesenb87f91b2011-08-03 23:09:38 +0000286void SpillPlacement::addPrefSpill(ArrayRef<unsigned> Blocks, bool Strong) {
Jakob Stoklund Olesene60f1032011-07-23 03:10:19 +0000287 for (ArrayRef<unsigned>::iterator I = Blocks.begin(), E = Blocks.end();
288 I != E; ++I) {
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000289 BlockFrequency Freq = BlockFrequencies[*I];
Jakob Stoklund Olesenb87f91b2011-08-03 23:09:38 +0000290 if (Strong)
291 Freq += Freq;
Eugene Zelenko79ea5b52017-09-21 23:20:16 +0000292 unsigned ib = bundles->getBundle(*I, false);
293 unsigned ob = bundles->getBundle(*I, true);
Jakob Stoklund Olesene60f1032011-07-23 03:10:19 +0000294 activate(ib);
295 activate(ob);
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000296 nodes[ib].addBias(Freq, PrefSpill);
297 nodes[ob].addBias(Freq, PrefSpill);
Jakob Stoklund Olesene60f1032011-07-23 03:10:19 +0000298 }
299}
300
Jakob Stoklund Olesen7b41fbe2011-04-07 17:27:46 +0000301void SpillPlacement::addLinks(ArrayRef<unsigned> Links) {
302 for (ArrayRef<unsigned>::iterator I = Links.begin(), E = Links.end(); I != E;
303 ++I) {
304 unsigned Number = *I;
Eugene Zelenko79ea5b52017-09-21 23:20:16 +0000305 unsigned ib = bundles->getBundle(Number, false);
306 unsigned ob = bundles->getBundle(Number, true);
Jakob Stoklund Olesen7b41fbe2011-04-07 17:27:46 +0000307
308 // Ignore self-loops.
309 if (ib == ob)
310 continue;
311 activate(ib);
312 activate(ob);
Jakob Stoklund Olesen6d9fe792013-07-16 18:26:15 +0000313 BlockFrequency Freq = BlockFrequencies[Number];
314 nodes[ib].addLink(ob, Freq);
315 nodes[ob].addLink(ib, Freq);
Jakob Stoklund Olesen7b41fbe2011-04-07 17:27:46 +0000316 }
317}
318
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +0000319bool SpillPlacement::scanActiveBundles() {
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +0000320 RecentPositive.clear();
Francis Visoiu Mistrih1179b5e2017-05-17 01:07:53 +0000321 for (unsigned n : ActiveNodes->set_bits()) {
Quentin Colombeta4992162016-05-19 22:40:37 +0000322 update(n);
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +0000323 // A node that must spill, or a node without any links is not going to
324 // change its value ever again, so exclude it from iterations.
325 if (nodes[n].mustSpill())
326 continue;
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +0000327 if (nodes[n].preferReg())
328 RecentPositive.push_back(n);
329 }
330 return !RecentPositive.empty();
331}
332
Quentin Colombeta4992162016-05-19 22:40:37 +0000333bool SpillPlacement::update(unsigned n) {
334 if (!nodes[n].update(nodes, Threshold))
335 return false;
336 nodes[n].getDissentingNeighbors(TodoList, nodes);
337 return true;
338}
339
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000340/// iterate - Repeatedly update the Hopfield nodes until stability or the
341/// maximum number of iterations is reached.
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +0000342void SpillPlacement::iterate() {
Quentin Colombeta4992162016-05-19 22:40:37 +0000343 // We do not need to push those node in the todolist.
344 // They are already been proceeded as part of the previous iteration.
345 RecentPositive.clear();
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +0000346
Quentin Colombeta4992162016-05-19 22:40:37 +0000347 // Since the last iteration, the todolist have been augmented by calls
348 // to addConstraints, addLinks, and co.
349 // Update the network energy starting at this new frontier.
350 // The call to ::update will add the nodes that changed into the todolist.
351 unsigned Limit = bundles->getNumBundles() * 10;
352 while(Limit-- > 0 && !TodoList.empty()) {
353 unsigned n = TodoList.pop_back_val();
354 if (!update(n))
355 continue;
356 if (nodes[n].preferReg())
357 RecentPositive.push_back(n);
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000358 }
359}
360
Jakob Stoklund Olesen9efa2a22011-04-06 19:13:57 +0000361void SpillPlacement::prepare(BitVector &RegBundles) {
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +0000362 RecentPositive.clear();
Quentin Colombeta4992162016-05-19 22:40:37 +0000363 TodoList.clear();
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000364 // Reuse RegBundles as our ActiveNodes vector.
365 ActiveNodes = &RegBundles;
366 ActiveNodes->clear();
367 ActiveNodes->resize(bundles->getNumBundles());
Jakob Stoklund Olesen9efa2a22011-04-06 19:13:57 +0000368}
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000369
Jakob Stoklund Olesen9efa2a22011-04-06 19:13:57 +0000370bool
371SpillPlacement::finish() {
372 assert(ActiveNodes && "Call prepare() first");
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000373
Jakob Stoklund Olesen9efa2a22011-04-06 19:13:57 +0000374 // Write preferences back to ActiveNodes.
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000375 bool Perfect = true;
Francis Visoiu Mistrih1179b5e2017-05-17 01:07:53 +0000376 for (unsigned n : ActiveNodes->set_bits())
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000377 if (!nodes[n].preferReg()) {
Jakob Stoklund Olesen9efa2a22011-04-06 19:13:57 +0000378 ActiveNodes->reset(n);
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000379 Perfect = false;
380 }
Craig Topper4ba84432014-04-14 00:51:57 +0000381 ActiveNodes = nullptr;
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000382 return Perfect;
383}