@@ -1039,16 +1039,19 @@ static const VPBasicBlock *getIncomingBlockForRecipe(const VPRecipeBase *R,
10391039 return Pred->getExitingBasicBlock ();
10401040}
10411041
1042+ template <>
1043+ const VPBasicBlock *
1044+ VPPhiAccessors<VPIRPhi>::getIncomingBlock(unsigned Idx) const {
1045+ return getIncomingBlockForRecipe (getAsRecipe (), Idx);
1046+ }
1047+
10421048void VPIRPhi::execute (VPTransformState &State) {
10431049 PHINode *Phi = &getIRPhi ();
1044- for (const auto &[Idx, Op] : enumerate(operands ())) {
1045- VPValue *ExitValue = Op;
1050+ for (const auto &[ExitValue, IncVPBB] : incoming_values_and_blocks ()) {
10461051 auto Lane = vputils::isUniformAfterVectorization (ExitValue)
10471052 ? VPLane::getFirstLane ()
10481053 : VPLane::getLastLaneForVF (State.VF );
1049- VPBlockBase *Pred = getParent ()->getPredecessors ()[Idx];
1050- auto *PredVPBB = Pred->getExitingBasicBlock ();
1051- BasicBlock *PredBB = State.CFG .VPBB2IRBB [PredVPBB];
1054+ BasicBlock *PredBB = State.CFG .VPBB2IRBB [IncVPBB];
10521055 // Set insertion point in PredBB in case an extract needs to be generated.
10531056 // TODO: Model extracts explicitly.
10541057 State.Builder .SetInsertPoint (PredBB, PredBB->getFirstNonPHIIt ());
@@ -1073,12 +1076,11 @@ void VPIRPhi::print(raw_ostream &O, const Twine &Indent,
10731076
10741077 if (getNumOperands () != 0 ) {
10751078 O << " (extra operand" << (getNumOperands () > 1 ? " s" : " " ) << " : " ;
1076- interleaveComma (
1077- enumerate(operands ()), O, [this , &O, &SlotTracker](auto Op) {
1078- Op.value ()->printAsOperand (O, SlotTracker);
1079- O << " from " ;
1080- getParent ()->getPredecessors ()[Op.index ()]->printAsOperand (O);
1081- });
1079+ interleaveComma (incoming_values_and_blocks (), O, [&O, &SlotTracker](auto Op) {
1080+ std::get<0 >(Op)->printAsOperand (O, SlotTracker);
1081+ O << " from " ;
1082+ std::get<1 >(Op)->printAsOperand (O);
1083+ });
10821084 O << " )" ;
10831085 }
10841086}
0 commit comments