@@ -1039,16 +1039,19 @@ static const VPBasicBlock *getIncomingBlockForRecipe(const VPRecipeBase *R,
1039
1039
return Pred->getExitingBasicBlock ();
1040
1040
}
1041
1041
1042
+ template <>
1043
+ const VPBasicBlock *
1044
+ VPPhiAccessors<VPIRPhi>::getIncomingBlock(unsigned Idx) const {
1045
+ return getIncomingBlockForRecipe (getAsRecipe (), Idx);
1046
+ }
1047
+
1042
1048
void VPIRPhi::execute (VPTransformState &State) {
1043
1049
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 ()) {
1046
1051
auto Lane = vputils::isUniformAfterVectorization (ExitValue)
1047
1052
? VPLane::getFirstLane ()
1048
1053
: 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];
1052
1055
// Set insertion point in PredBB in case an extract needs to be generated.
1053
1056
// TODO: Model extracts explicitly.
1054
1057
State.Builder .SetInsertPoint (PredBB, PredBB->getFirstNonPHIIt ());
@@ -1073,12 +1076,11 @@ void VPIRPhi::print(raw_ostream &O, const Twine &Indent,
1073
1076
1074
1077
if (getNumOperands () != 0 ) {
1075
1078
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
+ });
1082
1084
O << " )" ;
1083
1085
}
1084
1086
}
0 commit comments