@@ -456,10 +456,17 @@ void VPIRBasicBlock::execute(VPTransformState *State) {
456
456
State->Builder .SetInsertPoint (getIRBasicBlock ()->getTerminator ());
457
457
executeRecipes (State, getIRBasicBlock ());
458
458
if (getSingleSuccessor ()) {
459
- assert (isa<UnreachableInst>(getIRBasicBlock ()->getTerminator ()));
460
- auto *Br = State->Builder .CreateBr (getIRBasicBlock ());
461
- Br->setOperand (0 , nullptr );
462
- getIRBasicBlock ()->getTerminator ()->eraseFromParent ();
459
+ auto *SuccVPIRBB = dyn_cast<VPIRBasicBlock>(getSingleSuccessor ());
460
+ if (SuccVPIRBB && SuccVPIRBB->getIRBasicBlock () ==
461
+ getIRBasicBlock ()->getSingleSuccessor ()) {
462
+ cast<BranchInst>(getIRBasicBlock ()->getTerminator ())
463
+ ->setOperand (0 , nullptr );
464
+ } else {
465
+ assert (isa<UnreachableInst>(getIRBasicBlock ()->getTerminator ()));
466
+ auto *Br = State->Builder .CreateBr (getIRBasicBlock ());
467
+ Br->setOperand (0 , nullptr );
468
+ getIRBasicBlock ()->getTerminator ()->eraseFromParent ();
469
+ }
463
470
}
464
471
465
472
for (VPBlockBase *PredVPBlock : getHierarchicalPredecessors ()) {
@@ -843,10 +850,6 @@ void VPRegionBlock::print(raw_ostream &O, const Twine &Indent,
843
850
#endif
844
851
845
852
VPlan::~VPlan () {
846
- for (auto &KV : LiveOuts)
847
- delete KV.second ;
848
- LiveOuts.clear ();
849
-
850
853
if (Entry) {
851
854
VPValue DummyValue;
852
855
for (VPBlockBase *Block : vp_depth_first_shallow (Entry))
@@ -909,6 +912,9 @@ VPlanPtr VPlan::createInitialVPlan(Type *InductionTy,
909
912
VPBlockUtils::insertBlockAfter (MiddleVPBB, TopRegion);
910
913
911
914
VPBasicBlock *ScalarPH = new VPBasicBlock (" scalar.ph" );
915
+ VPBasicBlock *ScalarHeader =
916
+ VPIRBasicBlock::fromBasicBlock (TheLoop->getHeader ());
917
+ VPBlockUtils::connectBlocks (ScalarPH, ScalarHeader);
912
918
if (!RequiresScalarEpilogueCheck) {
913
919
VPBlockUtils::connectBlocks (MiddleVPBB, ScalarPH);
914
920
return Plan;
@@ -1058,6 +1064,8 @@ void VPlan::execute(VPTransformState *State) {
1058
1064
BrInst->insertBefore (MiddleBB->getTerminator ());
1059
1065
MiddleBB->getTerminator ()->eraseFromParent ();
1060
1066
State->CFG .DTU .applyUpdates ({{DominatorTree::Delete, MiddleBB, ScalarPh}});
1067
+ State->CFG .DTU .applyUpdates (
1068
+ {{DominatorTree::Delete, ScalarPh, ScalarPh->getSingleSuccessor ()}});
1061
1069
1062
1070
// Generate code in the loop pre-header and body.
1063
1071
for (VPBlockBase *Block : vp_depth_first_shallow (Entry))
@@ -1176,12 +1184,6 @@ void VPlan::print(raw_ostream &O) const {
1176
1184
Block->print (O, " " , SlotTracker);
1177
1185
}
1178
1186
1179
- if (!LiveOuts.empty ())
1180
- O << " \n " ;
1181
- for (const auto &KV : LiveOuts) {
1182
- KV.second ->print (O, SlotTracker);
1183
- }
1184
-
1185
1187
O << " }\n " ;
1186
1188
}
1187
1189
@@ -1218,11 +1220,6 @@ LLVM_DUMP_METHOD
1218
1220
void VPlan::dump () const { print (dbgs ()); }
1219
1221
#endif
1220
1222
1221
- void VPlan::addLiveOut (PHINode *PN, VPValue *V) {
1222
- assert (LiveOuts.count (PN) == 0 && " an exit value for PN already exists" );
1223
- LiveOuts.insert ({PN, new VPLiveOut (PN, V)});
1224
- }
1225
-
1226
1223
static void remapOperands (VPBlockBase *Entry, VPBlockBase *NewEntry,
1227
1224
DenseMap<VPValue *, VPValue *> &Old2NewVPValues) {
1228
1225
// Update the operands of all cloned recipes starting at NewEntry. This
@@ -1290,10 +1287,6 @@ VPlan *VPlan::duplicate() {
1290
1287
remapOperands (Preheader, NewPreheader, Old2NewVPValues);
1291
1288
remapOperands (Entry, NewEntry, Old2NewVPValues);
1292
1289
1293
- // Clone live-outs.
1294
- for (const auto &[_, LO] : LiveOuts)
1295
- NewPlan->addLiveOut (LO->getPhi (), Old2NewVPValues[LO->getOperand (0 )]);
1296
-
1297
1290
// Initialize remaining fields of cloned VPlan.
1298
1291
NewPlan->VFs = VFs;
1299
1292
NewPlan->UFs = UFs;
0 commit comments