File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -1961,7 +1961,7 @@ class VPScalarPHIRecipe : public VPHeaderPHIRecipe {
19611961// / A recipe for widened phis. Incoming values are operands of the recipe and
19621962// / their operand index corresponds to the incoming predeocessor block. If the
19631963// / recipe is placed in an entry block to a (non-replicate) region, it must have
1964- // / exactly 2 incoming values, from from the predecessors of the region and one
1964+ // / exactly 2 incoming values, the first from the predecessors of the region and the second
19651965// / from the exiting block of the region.
19661966class VPWidenPHIRecipe : public VPSingleDefRecipe {
19671967public:
Original file line number Diff line number Diff line change @@ -145,13 +145,13 @@ void PlainCFGBuilder::fixPhiNodes() {
145145 }
146146
147147 // Add operands for VPPhi in the order matching its predecessors in VPlan.
148- DenseMap<const VPBasicBlock *, VPValue *> IncomingValues ;
148+ DenseMap<const VPBasicBlock *, VPValue *> VPPredToIncomingValue ;
149149 for (unsigned I = 0 ; I != Phi->getNumOperands (); ++I) {
150- IncomingValues [BB2VPBB[Phi->getIncomingBlock (I)]] =
150+ VPPredToIncomingValue [BB2VPBB[Phi->getIncomingBlock (I)]] =
151151 getOrCreateVPOperand (Phi->getIncomingValue (I));
152152 }
153153 for (VPBlockBase *Pred : VPPhi->getParent ()->getPredecessors ())
154- VPPhi->addOperand (IncomingValues .lookup (Pred->getExitingBasicBlock ()));
154+ VPPhi->addOperand (VPPredToIncomingValue .lookup (Pred->getExitingBasicBlock ()));
155155 }
156156}
157157
Original file line number Diff line number Diff line change @@ -3613,10 +3613,12 @@ VPBasicBlock *VPWidenPHIRecipe::getIncomingBlock(unsigned I) {
36133613 VPBasicBlock *Parent = getParent ();
36143614 VPBlockBase *Pred = nullptr ;
36153615 if (Parent->getNumPredecessors () == 0 ) {
3616- auto *R = Parent->getParent ();
3617- assert (R && R->getEntry () == Parent);
3618- assert (I < 2 );
3619- Pred = I == 0 ? R->getSinglePredecessor () : R;
3616+ auto *Region = Parent->getParent ();
3617+ assert (Region && !Region->isReplicator () && Region->getEntry () == Parent && " must be in the entry block of a non-replicate region" );
3618+ assert (I < 2 && getNumOperands () == 2 && " when placed in an entry block, only 2 incoming blocks are available" );
3619+
3620+ // I == 0 selects the predecessor of the region, I == 1 selects the region itself whose exiting block feeds the phi across the backedge.
3621+ Pred = I == 0 ? Region->getSinglePredecessor () : Region;
36203622 } else {
36213623 Pred = Parent->getPredecessors ()[I];
36223624 }
You can’t perform that action at this time.
0 commit comments