Skip to content

Commit 3cfe25b

Browse files
committed
[VPlan] Support VPIRBBs and VPIRInst phis with multiple predecessors.
1 parent 98c9523 commit 3cfe25b

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,10 @@ void VPlan::execute(VPTransformState *State) {
10531053
State->CFG.DTU.applyUpdates({{DominatorTree::Delete, MiddleBB, ScalarPh}});
10541054

10551055
// Generate code in the loop pre-header and body.
1056-
for (VPBlockBase *Block : vp_depth_first_shallow(Entry))
1056+
ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
1057+
Entry);
1058+
1059+
for (VPBlockBase *Block : RPOT)
10571060
Block->execute(State);
10581061

10591062
VPBasicBlock *LatchVPBB = getVectorLoopRegion()->getExitingBasicBlock();

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -843,12 +843,13 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
843843
void VPIRInstruction::execute(VPTransformState &State) {
844844
assert((isa<PHINode>(&I) || getNumOperands() == 0) &&
845845
"Only PHINodes can have extra operands");
846-
if (getNumOperands() == 1) {
847-
VPValue *ExitValue = getOperand(0);
846+
for (const auto &[Idx, Op] : enumerate(operands())) {
847+
VPValue *ExitValue = Op;
848848
auto Lane = vputils::isUniformAfterVectorization(ExitValue)
849849
? VPLane::getFirstLane()
850850
: VPLane::getLastLaneForVF(State.VF);
851-
auto *PredVPBB = cast<VPBasicBlock>(getParent()->getSinglePredecessor());
851+
VPBlockBase *Pred = getParent()->getPredecessors()[Idx];
852+
auto *PredVPBB = Pred->getExitingBasicBlock();
852853
BasicBlock *PredBB = State.CFG.VPBB2IRBB[PredVPBB];
853854
// Set insertion point in PredBB in case an extract needs to be generated.
854855
// TODO: Model extracts explicitly.
@@ -869,7 +870,7 @@ void VPIRInstruction::print(raw_ostream &O, const Twine &Indent,
869870
O << Indent << "IR " << I;
870871

871872
if (getNumOperands() != 0) {
872-
assert(getNumOperands() == 1 && "can have at most 1 operand");
873+
// assert(getNumOperands() == 1 && "can have at most 1 operand");
873874
O << " (extra operand: ";
874875
printOperands(O, SlotTracker);
875876
O << ")";

0 commit comments

Comments
 (0)