@@ -1168,16 +1168,11 @@ VPlan *VPlan::duplicate() {
11681168 const auto &[NewEntry, __] = cloneFrom (Entry);
11691169
11701170 BasicBlock *ScalarHeaderIRBB = getScalarHeader ()->getIRBasicBlock ();
1171- VPIRBasicBlock *NewScalarHeader = nullptr ;
1172- if (getScalarHeader ()->getNumPredecessors () == 0 ) {
1173- NewScalarHeader = createVPIRBasicBlock (ScalarHeaderIRBB);
1174- } else {
1175- NewScalarHeader = cast<VPIRBasicBlock>(*find_if (
1176- vp_depth_first_shallow (NewEntry), [ScalarHeaderIRBB](VPBlockBase *VPB) {
1177- auto *VPIRBB = dyn_cast<VPIRBasicBlock>(VPB);
1178- return VPIRBB && VPIRBB->getIRBasicBlock () == ScalarHeaderIRBB;
1179- }));
1180- }
1171+ VPIRBasicBlock *NewScalarHeader = cast<VPIRBasicBlock>(*find_if (
1172+ vp_depth_first_shallow (NewEntry), [ScalarHeaderIRBB](VPBlockBase *VPB) {
1173+ auto *VPIRBB = dyn_cast<VPIRBasicBlock>(VPB);
1174+ return VPIRBB && VPIRBB->getIRBasicBlock () == ScalarHeaderIRBB;
1175+ }));
11811176 // Create VPlan, clone live-ins and remap operands in the cloned blocks.
11821177 auto *NewPlan = new VPlan (cast<VPBasicBlock>(NewEntry), NewScalarHeader);
11831178 DenseMap<VPValue *, VPValue *> Old2NewVPValues;
@@ -1192,7 +1187,8 @@ VPlan *VPlan::duplicate() {
11921187 NewPlan->BackedgeTakenCount = new VPValue ();
11931188 Old2NewVPValues[BackedgeTakenCount] = NewPlan->BackedgeTakenCount ;
11941189 }
1195- if (TripCount && TripCount->isLiveIn ())
1190+ assert (TripCount && " trip count must be set" );
1191+ if (TripCount->isLiveIn ())
11961192 Old2NewVPValues[TripCount] =
11971193 NewPlan->getOrAddLiveIn (TripCount->getLiveInIRValue ());
11981194 // else NewTripCount will be created and inserted into Old2NewVPValues when
@@ -1205,11 +1201,9 @@ VPlan *VPlan::duplicate() {
12051201 NewPlan->UFs = UFs;
12061202 // TODO: Adjust names.
12071203 NewPlan->Name = Name;
1208- if (TripCount) {
1209- assert (Old2NewVPValues.contains (TripCount) &&
1210- " TripCount must have been added to Old2NewVPValues" );
1211- NewPlan->TripCount = Old2NewVPValues[TripCount];
1212- }
1204+ assert (Old2NewVPValues.contains (TripCount) &&
1205+ " TripCount must have been added to Old2NewVPValues" );
1206+ NewPlan->TripCount = Old2NewVPValues[TripCount];
12131207
12141208 // Transfer all cloned blocks (the second half of all current blocks) from
12151209 // current to new VPlan.
0 commit comments