@@ -1168,16 +1168,11 @@ VPlan *VPlan::duplicate() {
1168
1168
const auto &[NewEntry, __] = cloneFrom (Entry);
1169
1169
1170
1170
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
+ }));
1181
1176
// Create VPlan, clone live-ins and remap operands in the cloned blocks.
1182
1177
auto *NewPlan = new VPlan (cast<VPBasicBlock>(NewEntry), NewScalarHeader);
1183
1178
DenseMap<VPValue *, VPValue *> Old2NewVPValues;
@@ -1192,7 +1187,8 @@ VPlan *VPlan::duplicate() {
1192
1187
NewPlan->BackedgeTakenCount = new VPValue ();
1193
1188
Old2NewVPValues[BackedgeTakenCount] = NewPlan->BackedgeTakenCount ;
1194
1189
}
1195
- if (TripCount && TripCount->isLiveIn ())
1190
+ assert (TripCount && " trip count must be set" );
1191
+ if (TripCount->isLiveIn ())
1196
1192
Old2NewVPValues[TripCount] =
1197
1193
NewPlan->getOrAddLiveIn (TripCount->getLiveInIRValue ());
1198
1194
// else NewTripCount will be created and inserted into Old2NewVPValues when
@@ -1205,11 +1201,9 @@ VPlan *VPlan::duplicate() {
1205
1201
NewPlan->UFs = UFs;
1206
1202
// TODO: Adjust names.
1207
1203
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];
1213
1207
1214
1208
// Transfer all cloned blocks (the second half of all current blocks) from
1215
1209
// current to new VPlan.
0 commit comments