@@ -483,24 +483,20 @@ static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
483
483
484
484
// Prepare for the iteration by collecting any simplified entry or backedge
485
485
// inputs.
486
- for (Instruction &I : *L->getHeader ()) {
487
- auto *PHI = dyn_cast<PHINode>(&I);
488
- if (!PHI)
489
- break ;
490
-
486
+ for (PHINode &PHI : L->getHeader ()->phis ()) {
491
487
// The loop header PHI nodes must have exactly two input: one from the
492
488
// loop preheader and one from the loop latch.
493
489
assert (
494
- PHI-> getNumIncomingValues () == 2 &&
490
+ PHI. getNumIncomingValues () == 2 &&
495
491
" Must have an incoming value only for the preheader and the latch." );
496
492
497
- Value *V = PHI-> getIncomingValueForBlock (
493
+ Value *V = PHI. getIncomingValueForBlock (
498
494
Iteration == 0 ? L->getLoopPreheader () : L->getLoopLatch ());
499
495
Constant *C = dyn_cast<Constant>(V);
500
496
if (Iteration != 0 && !C)
501
497
C = SimplifiedValues.lookup (V);
502
498
if (C)
503
- SimplifiedInputValues.push_back ({PHI, C});
499
+ SimplifiedInputValues.push_back ({& PHI, C});
504
500
}
505
501
506
502
// Now clear and re-populate the map for the next iteration.
@@ -625,12 +621,8 @@ static Optional<EstimatedUnrollCost> analyzeLoopUnrollCost(
625
621
BasicBlock *ExitingBB, *ExitBB;
626
622
std::tie (ExitingBB, ExitBB) = ExitWorklist.pop_back_val ();
627
623
628
- for (Instruction &I : *ExitBB) {
629
- auto *PN = dyn_cast<PHINode>(&I);
630
- if (!PN)
631
- break ;
632
-
633
- Value *Op = PN->getIncomingValueForBlock (ExitingBB);
624
+ for (PHINode &PN : ExitBB->phis ()) {
625
+ Value *Op = PN.getIncomingValueForBlock (ExitingBB);
634
626
if (auto *OpI = dyn_cast<Instruction>(Op))
635
627
if (L->contains (OpI))
636
628
AddCostRecursively (*OpI, TripCount - 1 );
0 commit comments