Skip to content

Commit 245b56a

Browse files
committed
[VPlan] Support VPIRBBs and VPIRInst phis with multiple predecessors.
1 parent dac0f7e commit 245b56a

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
@@ -1056,7 +1056,10 @@ void VPlan::execute(VPTransformState *State) {
10561056
State->CFG.DTU.applyUpdates({{DominatorTree::Delete, MiddleBB, ScalarPh}});
10571057

10581058
// Generate code in the loop pre-header and body.
1059-
for (VPBlockBase *Block : vp_depth_first_shallow(Entry))
1059+
ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
1060+
Entry);
1061+
1062+
for (VPBlockBase *Block : RPOT)
10601063
Block->execute(State);
10611064

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

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,12 +857,13 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
857857
void VPIRInstruction::execute(VPTransformState &State) {
858858
assert((isa<PHINode>(&I) || getNumOperands() == 0) &&
859859
"Only PHINodes can have extra operands");
860-
if (getNumOperands() == 1) {
861-
VPValue *ExitValue = getOperand(0);
860+
for (const auto &[Idx, Op] : enumerate(operands())) {
861+
VPValue *ExitValue = Op;
862862
auto Lane = vputils::isUniformAfterVectorization(ExitValue)
863863
? VPLane::getFirstLane()
864864
: VPLane::getLastLaneForVF(State.VF);
865-
auto *PredVPBB = cast<VPBasicBlock>(getParent()->getSinglePredecessor());
865+
VPBlockBase *Pred = getParent()->getPredecessors()[Idx];
866+
auto *PredVPBB = Pred->getExitingBasicBlock();
866867
BasicBlock *PredBB = State.CFG.VPBB2IRBB[PredVPBB];
867868
// Set insertion point in PredBB in case an extract needs to be generated.
868869
// TODO: Model extracts explicitly.
@@ -890,7 +891,7 @@ void VPIRInstruction::print(raw_ostream &O, const Twine &Indent,
890891
O << Indent << "IR " << I;
891892

892893
if (getNumOperands() != 0) {
893-
assert(getNumOperands() == 1 && "can have at most 1 operand");
894+
// assert(getNumOperands() == 1 && "can have at most 1 operand");
894895
O << " (extra operand: ";
895896
printOperands(O, SlotTracker);
896897
O << ")";

0 commit comments

Comments
 (0)