@@ -290,38 +290,34 @@ Cost InstCostVisitor::estimateBranchInst(BranchInst &I) {
290
290
// A depth limit is used to avoid extreme recurusion.
291
291
// A max number of incoming phi values ensures that expensive searches
292
292
// are avoided.
293
- //
294
- // Returns false if the discovery was aborted due to the above conditions.
295
- bool InstCostVisitor::discoverTransitivelyIncomngValues (
293
+ void InstCostVisitor::discoverTransitivelyIncomngValues (
296
294
DenseSet<PHINode *> &PHINodes, PHINode *PN, unsigned Depth) {
297
295
if (Depth > MaxDiscoveryDepth) {
298
296
LLVM_DEBUG (dbgs () << " FnSpecialization: Discover PHI nodes too deep ("
299
297
<< Depth << " >" << MaxDiscoveryDepth << " )\n " );
300
- return false ;
298
+ return ;
301
299
}
302
300
303
301
if (PN->getNumIncomingValues () > MaxIncomingPhiValues) {
304
302
LLVM_DEBUG (
305
303
dbgs () << " FnSpecialization: Discover PHI nodes has too many values ("
306
304
<< PN->getNumIncomingValues () << " >" << MaxIncomingPhiValues
307
305
<< " )\n " );
308
- return false ;
306
+ return ;
309
307
}
310
308
311
309
// Already seen this, no more processing needed.
312
310
if (!PHINodes.insert (PN).second )
313
- return true ;
311
+ return ;
314
312
315
313
for (unsigned I = 0 , E = PN->getNumIncomingValues (); I != E; ++I) {
316
314
Value *V = PN->getIncomingValue (I);
317
315
if (auto *Phi = dyn_cast<PHINode>(V)) {
318
316
if (Phi == PN || DeadBlocks.contains (PN->getIncomingBlock (I)))
319
317
continue ;
320
- if (!discoverTransitivelyIncomngValues (PHINodes, Phi, Depth + 1 ))
321
- return false ;
318
+ discoverTransitivelyIncomngValues (PHINodes, Phi, Depth + 1 );
322
319
}
323
320
}
324
- return true ;
325
321
}
326
322
327
323
Constant *InstCostVisitor::visitPHINode (PHINode &I) {
@@ -378,8 +374,8 @@ Constant *InstCostVisitor::visitPHINode(PHINode &I) {
378
374
// Try to see if we can collect a nest of transitive phis. Bail if
379
375
// it's too complex.
380
376
for (PHINode *Phi : UnknownIncomingValues)
381
- if (! discoverTransitivelyIncomngValues (TransitivePHIs, Phi, 1 ))
382
- return nullptr ;
377
+ discoverTransitivelyIncomngValues (TransitivePHIs, Phi, 1 );
378
+
383
379
384
380
// A nested set of PHINodes can be constantfolded if:
385
381
// - It has a constant input.
0 commit comments