Skip to content

Commit 79d5c6a

Browse files
committed
[VPlan] Support VPIRBBs and VPIRInst phis with multiple predecessors.
1 parent 48deb35 commit 79d5c6a

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

10621062
// Generate code in the loop pre-header and body.
1063-
for (VPBlockBase *Block : vp_depth_first_shallow(Entry))
1063+
ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
1064+
Entry);
1065+
1066+
for (VPBlockBase *Block : RPOT)
10641067
Block->execute(State);
10651068

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

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

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

883884
if (getNumOperands() != 0) {
884-
assert(getNumOperands() == 1 && "can have at most 1 operand");
885+
// assert(getNumOperands() == 1 && "can have at most 1 operand");
885886
O << " (extra operand: ";
886887
printOperands(O, SlotTracker);
887888
O << ")";

0 commit comments

Comments
 (0)