@@ -580,10 +580,13 @@ void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
580580
581581 // Check if R is a dead VPPhi <-> update cycle and remove it.
582582 auto *PhiR = dyn_cast<VPPhi>(&R);
583- if (!PhiR || PhiR->getNumOperands () != 2 || PhiR->getNumUsers () != 1 )
583+ if (!PhiR || PhiR->getNumOperands () != 2 )
584+ continue ;
585+ VPUser *PhiUser = PhiR->getSingleUser ();
586+ if (!PhiUser)
584587 continue ;
585588 VPValue *Incoming = PhiR->getOperand (1 );
586- if (*PhiR-> user_begin () != Incoming->getDefiningRecipe () ||
589+ if (PhiUser != Incoming->getDefiningRecipe () ||
587590 Incoming->getNumUsers () != 1 )
588591 continue ;
589592 PhiR->replaceAllUsesWith (PhiR->getOperand (0 ));
@@ -1307,7 +1310,7 @@ static void simplifyRecipe(VPSingleDefRecipe *Def, VPTypeAnalysis &TypeInfo) {
13071310 isa<VPPhi>(X)) {
13081311 auto *Phi = cast<VPPhi>(X);
13091312 if (Phi->getOperand (1 ) != Def && match (Phi->getOperand (0 ), m_ZeroInt ()) &&
1310- Phi->getNumUsers () == 1 && (*Phi-> user_begin () == Def) ) {
1313+ Phi->getSingleUser () == Def) {
13111314 Phi->setOperand (0 , Y);
13121315 Def->replaceAllUsesWith (Phi);
13131316 return ;
@@ -1592,10 +1595,11 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
15921595
15931596 // Currently only handle cases where the single user is a header-mask
15941597 // comparison with the backedge-taken-count.
1595- if (!match (*WideIV->user_begin (),
1596- m_ICmp (m_Specific (WideIV),
1597- m_Broadcast (
1598- m_Specific (Plan.getOrCreateBackedgeTakenCount ())))))
1598+ VPUser *SingleUser = WideIV->getSingleUser ();
1599+ if (!SingleUser ||
1600+ !match (SingleUser, m_ICmp (m_Specific (WideIV),
1601+ m_Broadcast (m_Specific (
1602+ Plan.getOrCreateBackedgeTakenCount ())))))
15991603 continue ;
16001604
16011605 // Update IV operands and comparison bound to use new narrower type.
@@ -1607,7 +1611,7 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
16071611 auto *NewBTC = new VPWidenCastRecipe (
16081612 Instruction::Trunc, Plan.getOrCreateBackedgeTakenCount (), NewIVTy);
16091613 Plan.getVectorPreheader ()->appendRecipe (NewBTC);
1610- auto *Cmp = cast<VPInstruction>(* WideIV->user_begin ());
1614+ auto *Cmp = cast<VPInstruction>(WideIV->getSingleUser ());
16111615 Cmp->setOperand (1 , NewBTC);
16121616
16131617 MadeChange = true ;
0 commit comments