@@ -1028,16 +1028,19 @@ static const VPBasicBlock *getIncomingBlockForRecipe(const VPRecipeBase *R,
10281028 return Pred->getExitingBasicBlock ();
10291029}
10301030
1031+ template <>
1032+ const VPBasicBlock *
1033+ VPPhiAccessors<VPIRPhi>::getIncomingBlock(unsigned Idx) const {
1034+ return getIncomingBlockForRecipe (getAsRecipe (), Idx);
1035+ }
1036+
10311037void VPIRPhi::execute (VPTransformState &State) {
10321038 PHINode *Phi = &getIRPhi ();
1033- for (const auto &[Idx, Op] : enumerate(operands ())) {
1034- VPValue *ExitValue = Op;
1039+ for (const auto &[ExitValue, IncVPBB] : incoming_values_and_blocks ()) {
10351040 auto Lane = vputils::isUniformAfterVectorization (ExitValue)
10361041 ? VPLane::getFirstLane ()
10371042 : VPLane::getLastLaneForVF (State.VF );
1038- VPBlockBase *Pred = getParent ()->getPredecessors ()[Idx];
1039- auto *PredVPBB = Pred->getExitingBasicBlock ();
1040- BasicBlock *PredBB = State.CFG .VPBB2IRBB [PredVPBB];
1043+ BasicBlock *PredBB = State.CFG .VPBB2IRBB [IncVPBB];
10411044 // Set insertion point in PredBB in case an extract needs to be generated.
10421045 // TODO: Model extracts explicitly.
10431046 State.Builder .SetInsertPoint (PredBB, PredBB->getFirstNonPHIIt ());
@@ -1062,12 +1065,11 @@ void VPIRPhi::print(raw_ostream &O, const Twine &Indent,
10621065
10631066 if (getNumOperands () != 0 ) {
10641067 O << " (extra operand" << (getNumOperands () > 1 ? " s" : " " ) << " : " ;
1065- interleaveComma (
1066- enumerate(operands ()), O, [this , &O, &SlotTracker](auto Op) {
1067- Op.value ()->printAsOperand (O, SlotTracker);
1068- O << " from " ;
1069- getParent ()->getPredecessors ()[Op.index ()]->printAsOperand (O);
1070- });
1068+ interleaveComma (incoming_values_and_blocks (), O, [&O, &SlotTracker](auto Op) {
1069+ std::get<0 >(Op)->printAsOperand (O, SlotTracker);
1070+ O << " from " ;
1071+ std::get<1 >(Op)->printAsOperand (O);
1072+ });
10711073 O << " )" ;
10721074 }
10731075}
0 commit comments