@@ -242,8 +242,8 @@ Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
242
242
return Data.PerPartScalars [Def][Instance.Part ][0 ];
243
243
}
244
244
245
- assert (hasVectorValue (Def, Instance. Part ));
246
- auto *VecPart = Data.PerPartOutput [Def][Instance. Part ];
245
+ assert (hasVectorValue (Def));
246
+ auto *VecPart = Data.VPV2Vector [Def];
247
247
if (!VecPart->getType ()->isVectorTy ()) {
248
248
assert (Instance.Lane .isFirstLane () && " cannot get lane > 0 for scalar" );
249
249
return VecPart;
@@ -255,20 +255,20 @@ Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
255
255
return Extract;
256
256
}
257
257
258
- Value *VPTransformState::get (VPValue *Def, unsigned Part, bool NeedsScalar) {
258
+ Value *VPTransformState::get (VPValue *Def, bool NeedsScalar) {
259
259
if (NeedsScalar) {
260
- assert ((VF.isScalar () || Def->isLiveIn () || hasVectorValue (Def, Part ) ||
260
+ assert ((VF.isScalar () || Def->isLiveIn () || hasVectorValue (Def) ||
261
261
!vputils::onlyFirstLaneUsed (Def) ||
262
- (hasScalarValue (Def, VPIteration (Part , 0 )) &&
263
- Data.PerPartScalars [Def][Part ].size () == 1 )) &&
262
+ (hasScalarValue (Def, VPIteration (0 , 0 )) &&
263
+ Data.PerPartScalars [Def][0 ].size () == 1 )) &&
264
264
" Trying to access a single scalar per part but has multiple scalars "
265
265
" per part." );
266
- return get (Def, VPIteration (Part , 0 ));
266
+ return get (Def, VPIteration (0 , 0 ));
267
267
}
268
268
269
269
// If Values have been set for this Def return the one relevant for \p Part.
270
- if (hasVectorValue (Def, Part ))
271
- return Data.PerPartOutput [Def][Part ];
270
+ if (hasVectorValue (Def))
271
+ return Data.VPV2Vector [Def];
272
272
273
273
auto GetBroadcastInstrs = [this , Def](Value *V) {
274
274
bool SafeToHoist = Def->isDefinedOutsideLoopRegions ();
@@ -290,29 +290,27 @@ Value *VPTransformState::get(VPValue *Def, unsigned Part, bool NeedsScalar) {
290
290
return Shuf;
291
291
};
292
292
293
- if (!hasScalarValue (Def, {Part , 0 })) {
293
+ if (!hasScalarValue (Def, {0 , 0 })) {
294
294
assert (Def->isLiveIn () && " expected a live-in" );
295
- if (Part != 0 )
296
- return get (Def, 0 );
297
295
Value *IRV = Def->getLiveInIRValue ();
298
296
Value *B = GetBroadcastInstrs (IRV);
299
- set (Def, B, Part );
297
+ set (Def, B);
300
298
return B;
301
299
}
302
300
303
- Value *ScalarValue = get (Def, {Part , 0 });
301
+ Value *ScalarValue = get (Def, {0 , 0 });
304
302
// If we aren't vectorizing, we can just copy the scalar map values over
305
303
// to the vector map.
306
304
if (VF.isScalar ()) {
307
- set (Def, ScalarValue, Part );
305
+ set (Def, ScalarValue);
308
306
return ScalarValue;
309
307
}
310
308
311
309
bool IsUniform = vputils::isUniformAfterVectorization (Def);
312
310
313
311
unsigned LastLane = IsUniform ? 0 : VF.getKnownMinValue () - 1 ;
314
312
// Check if there is a scalar value for the selected lane.
315
- if (!hasScalarValue (Def, {Part , LastLane})) {
313
+ if (!hasScalarValue (Def, {0 , LastLane})) {
316
314
// At the moment, VPWidenIntOrFpInductionRecipes, VPScalarIVStepsRecipes and
317
315
// VPExpandSCEVRecipes can also be uniform.
318
316
assert ((isa<VPWidenIntOrFpInductionRecipe>(Def->getDefiningRecipe ()) ||
@@ -323,7 +321,7 @@ Value *VPTransformState::get(VPValue *Def, unsigned Part, bool NeedsScalar) {
323
321
LastLane = 0 ;
324
322
}
325
323
326
- auto *LastInst = cast<Instruction>(get (Def, {Part , LastLane}));
324
+ auto *LastInst = cast<Instruction>(get (Def, {0 , LastLane}));
327
325
// Set the insert point after the last scalarized instruction or after the
328
326
// last PHI, if LastInst is a PHI. This ensures the insertelement sequence
329
327
// will directly follow the scalar definitions.
@@ -343,15 +341,15 @@ Value *VPTransformState::get(VPValue *Def, unsigned Part, bool NeedsScalar) {
343
341
Value *VectorValue = nullptr ;
344
342
if (IsUniform) {
345
343
VectorValue = GetBroadcastInstrs (ScalarValue);
346
- set (Def, VectorValue, Part );
344
+ set (Def, VectorValue);
347
345
} else {
348
346
// Initialize packing with insertelements to start from undef.
349
347
assert (!VF.isScalable () && " VF is assumed to be non scalable." );
350
348
Value *Undef = PoisonValue::get (VectorType::get (LastInst->getType (), VF));
351
- set (Def, Undef, Part );
349
+ set (Def, Undef);
352
350
for (unsigned Lane = 0 ; Lane < VF.getKnownMinValue (); ++Lane)
353
- packScalarIntoVectorValue (Def, {Part , Lane});
354
- VectorValue = get (Def, Part );
351
+ packScalarIntoVectorValue (Def, {0 , Lane});
352
+ VectorValue = get (Def);
355
353
}
356
354
Builder.restoreIP (OldIP);
357
355
return VectorValue;
@@ -406,10 +404,10 @@ void VPTransformState::setDebugLocFrom(DebugLoc DL) {
406
404
void VPTransformState::packScalarIntoVectorValue (VPValue *Def,
407
405
const VPIteration &Instance) {
408
406
Value *ScalarInst = get (Def, Instance);
409
- Value *VectorValue = get (Def, Instance. Part );
407
+ Value *VectorValue = get (Def);
410
408
VectorValue = Builder.CreateInsertElement (
411
409
VectorValue, ScalarInst, Instance.Lane .getAsRuntimeExpr (Builder, VF));
412
- set (Def, VectorValue, Instance. Part );
410
+ set (Def, VectorValue);
413
411
}
414
412
415
413
BasicBlock *
@@ -1074,12 +1072,12 @@ void VPlan::execute(VPTransformState *State) {
1074
1072
isa<VPWidenIntOrFpInductionRecipe>(&R)) {
1075
1073
PHINode *Phi = nullptr ;
1076
1074
if (isa<VPWidenIntOrFpInductionRecipe>(&R)) {
1077
- Phi = cast<PHINode>(State->get (R.getVPSingleValue (), 0 ));
1075
+ Phi = cast<PHINode>(State->get (R.getVPSingleValue ()));
1078
1076
} else {
1079
1077
auto *WidenPhi = cast<VPWidenPointerInductionRecipe>(&R);
1080
1078
assert (!WidenPhi->onlyScalarsGenerated (State->VF .isScalable ()) &&
1081
1079
" recipe generating only scalars should have been replaced" );
1082
- auto *GEP = cast<GetElementPtrInst>(State->get (WidenPhi, 0 ));
1080
+ auto *GEP = cast<GetElementPtrInst>(State->get (WidenPhi));
1083
1081
Phi = cast<PHINode>(GEP->getPointerOperand ());
1084
1082
}
1085
1083
@@ -1092,7 +1090,7 @@ void VPlan::execute(VPTransformState *State) {
1092
1090
1093
1091
// Use the steps for the last part as backedge value for the induction.
1094
1092
if (auto *IV = dyn_cast<VPWidenIntOrFpInductionRecipe>(&R))
1095
- Inc->setOperand (0 , State->get (IV->getLastUnrolledPartOperand (), 0 ));
1093
+ Inc->setOperand (0 , State->get (IV->getLastUnrolledPartOperand ()));
1096
1094
continue ;
1097
1095
}
1098
1096
@@ -1101,8 +1099,8 @@ void VPlan::execute(VPTransformState *State) {
1101
1099
isa<VPCanonicalIVPHIRecipe, VPEVLBasedIVPHIRecipe>(PhiR) ||
1102
1100
(isa<VPReductionPHIRecipe>(PhiR) &&
1103
1101
cast<VPReductionPHIRecipe>(PhiR)->isInLoop ());
1104
- Value *Phi = State->get (PhiR, 0 , NeedsScalar);
1105
- Value *Val = State->get (PhiR->getBackedgeValue (), 0 , NeedsScalar);
1102
+ Value *Phi = State->get (PhiR, NeedsScalar);
1103
+ Value *Val = State->get (PhiR->getBackedgeValue (), NeedsScalar);
1106
1104
cast<PHINode>(Phi)->addIncoming (Val, VectorLatchBB);
1107
1105
}
1108
1106
0 commit comments