@@ -9316,52 +9316,6 @@ void VPReplicateRecipe::execute(VPTransformState &State) {
9316
9316
State.ILV ->scalarizeInstruction (UI, this , VPIteration (Part, Lane), State);
9317
9317
}
9318
9318
9319
- // / Creates either vp_store or vp_scatter intrinsics calls to represent
9320
- // / predicated store/scatter.
9321
- static Instruction *
9322
- lowerStoreUsingVectorIntrinsics (IRBuilderBase &Builder, Value *Addr,
9323
- Value *StoredVal, bool IsScatter, Value *Mask,
9324
- Value *EVL, const Align &Alignment) {
9325
- CallInst *Call;
9326
- if (IsScatter) {
9327
- Call = Builder.CreateIntrinsic (Type::getVoidTy (EVL->getContext ()),
9328
- Intrinsic::vp_scatter,
9329
- {StoredVal, Addr, Mask, EVL});
9330
- } else {
9331
- VectorBuilder VBuilder (Builder);
9332
- VBuilder.setEVL (EVL).setMask (Mask);
9333
- Call = cast<CallInst>(VBuilder.createVectorInstruction (
9334
- Instruction::Store, Type::getVoidTy (EVL->getContext ()),
9335
- {StoredVal, Addr}));
9336
- }
9337
- Call->addParamAttr (
9338
- 1 , Attribute::getWithAlignment (Call->getContext (), Alignment));
9339
- return Call;
9340
- }
9341
-
9342
- // / Creates either vp_load or vp_gather intrinsics calls to represent
9343
- // / predicated load/gather.
9344
- static Instruction *lowerLoadUsingVectorIntrinsics (IRBuilderBase &Builder,
9345
- VectorType *DataTy,
9346
- Value *Addr, bool IsGather,
9347
- Value *Mask, Value *EVL,
9348
- const Align &Alignment) {
9349
- CallInst *Call;
9350
- if (IsGather) {
9351
- Call =
9352
- Builder.CreateIntrinsic (DataTy, Intrinsic::vp_gather, {Addr, Mask, EVL},
9353
- nullptr , " wide.masked.gather" );
9354
- } else {
9355
- VectorBuilder VBuilder (Builder);
9356
- VBuilder.setEVL (EVL).setMask (Mask);
9357
- Call = cast<CallInst>(VBuilder.createVectorInstruction (
9358
- Instruction::Load, DataTy, Addr, " vp.op.load" ));
9359
- }
9360
- Call->addParamAttr (
9361
- 0 , Attribute::getWithAlignment (Call->getContext (), Alignment));
9362
- return Call;
9363
- }
9364
-
9365
9319
void VPWidenLoadRecipe::execute (VPTransformState &State) {
9366
9320
auto *LI = cast<LoadInst>(&Ingredient);
9367
9321
@@ -9383,24 +9337,7 @@ void VPWidenLoadRecipe::execute(VPTransformState &State) {
9383
9337
Mask = Builder.CreateVectorReverse (Mask, " reverse" );
9384
9338
}
9385
9339
9386
- // TODO: split this into several classes for better design.
9387
- if (State.EVL ) {
9388
- assert (State.UF == 1 && " Expected only UF == 1 when vectorizing with "
9389
- " explicit vector length." );
9390
- assert (cast<VPInstruction>(State.EVL )->getOpcode () ==
9391
- VPInstruction::ExplicitVectorLength &&
9392
- " EVL must be VPInstruction::ExplicitVectorLength." );
9393
- Value *EVL = State.get (State.EVL , VPIteration (0 , 0 ));
9394
- // If EVL is not nullptr, then EVL must be a valid value set during plan
9395
- // creation, possibly default value = whole vector register length. EVL
9396
- // is created only if TTI prefers predicated vectorization, thus if EVL
9397
- // is not nullptr it also implies preference for predicated
9398
- // vectorization.
9399
- // FIXME: Support reverse loading after vp_reverse is added.
9400
- NewLI = lowerLoadUsingVectorIntrinsics (
9401
- Builder, DataTy, State.get (getAddr (), Part, !CreateGather),
9402
- CreateGather, Mask, EVL, Alignment);
9403
- } else if (CreateGather) {
9340
+ if (CreateGather) {
9404
9341
Value *VectorGep = State.get (getAddr (), Part);
9405
9342
NewLI = Builder.CreateMaskedGather (DataTy, VectorGep, Alignment, Mask,
9406
9343
nullptr , " wide.masked.gather" );
@@ -9425,6 +9362,44 @@ void VPWidenLoadRecipe::execute(VPTransformState &State) {
9425
9362
}
9426
9363
}
9427
9364
9365
+ void VPWidenVPLoadRecipe::execute (VPTransformState &State) {
9366
+ assert (State.UF == 1 && " Expected only UF == 1 when vectorizing with "
9367
+ " explicit vector length." );
9368
+ // FIXME: Support reverse loading after vp_reverse is added.
9369
+ assert (!isReverse () && " Reverse loads are not implemented yet." );
9370
+
9371
+ auto *LI = cast<LoadInst>(&Ingredient);
9372
+
9373
+ Type *ScalarDataTy = getLoadStoreType (&Ingredient);
9374
+ auto *DataTy = VectorType::get (ScalarDataTy, State.VF );
9375
+ const Align Alignment = getLoadStoreAlignment (&Ingredient);
9376
+ bool CreateGather = !isConsecutive ();
9377
+
9378
+ auto &Builder = State.Builder ;
9379
+ State.setDebugLocFrom (getDebugLoc ());
9380
+ CallInst *NewLI;
9381
+ Value *EVL = State.get (getEVL (), VPIteration (0 , 0 ));
9382
+ Value *Addr = State.get (getAddr (), 0 , !CreateGather);
9383
+ Value *Mask =
9384
+ getMask () ? State.get (getMask (), 0 )
9385
+ : Mask = Builder.CreateVectorSplat (State.VF , Builder.getTrue ());
9386
+ if (CreateGather) {
9387
+ NewLI =
9388
+ Builder.CreateIntrinsic (DataTy, Intrinsic::vp_gather, {Addr, Mask, EVL},
9389
+ nullptr , " wide.masked.gather" );
9390
+ } else {
9391
+ VectorBuilder VBuilder (Builder);
9392
+ VBuilder.setEVL (EVL).setMask (Mask);
9393
+ NewLI = cast<CallInst>(VBuilder.createVectorInstruction (
9394
+ Instruction::Load, DataTy, Addr, " vp.op.load" ));
9395
+ }
9396
+ NewLI->addParamAttr (
9397
+ 0 , Attribute::getWithAlignment (NewLI->getContext (), Alignment));
9398
+
9399
+ State.addMetadata (NewLI, LI);
9400
+ State.set (this , NewLI, 0 );
9401
+ }
9402
+
9428
9403
void VPWidenStoreRecipe::execute (VPTransformState &State) {
9429
9404
auto *SI = cast<StoreInst>(&Ingredient);
9430
9405
@@ -9448,31 +9423,14 @@ void VPWidenStoreRecipe::execute(VPTransformState &State) {
9448
9423
9449
9424
Value *StoredVal = State.get (StoredVPValue, Part);
9450
9425
if (isReverse ()) {
9451
- assert (!State.EVL && " reversing not yet implemented with EVL" );
9452
9426
// If we store to reverse consecutive memory locations, then we need
9453
9427
// to reverse the order of elements in the stored value.
9454
9428
StoredVal = Builder.CreateVectorReverse (StoredVal, " reverse" );
9455
9429
// We don't want to update the value in the map as it might be used in
9456
9430
// another expression. So don't call resetVectorValue(StoredVal).
9457
9431
}
9458
9432
// TODO: split this into several classes for better design.
9459
- if (State.EVL ) {
9460
- assert (State.UF == 1 && " Expected only UF == 1 when vectorizing with "
9461
- " explicit vector length." );
9462
- assert (cast<VPInstruction>(State.EVL )->getOpcode () ==
9463
- VPInstruction::ExplicitVectorLength &&
9464
- " EVL must be VPInstruction::ExplicitVectorLength." );
9465
- Value *EVL = State.get (State.EVL , VPIteration (0 , 0 ));
9466
- // If EVL is not nullptr, then EVL must be a valid value set during plan
9467
- // creation, possibly default value = whole vector register length. EVL
9468
- // is created only if TTI prefers predicated vectorization, thus if EVL
9469
- // is not nullptr it also implies preference for predicated
9470
- // vectorization.
9471
- // FIXME: Support reverse store after vp_reverse is added.
9472
- NewSI = lowerStoreUsingVectorIntrinsics (
9473
- Builder, State.get (getAddr (), Part, !CreateScatter), StoredVal,
9474
- CreateScatter, Mask, EVL, Alignment);
9475
- } else if (CreateScatter) {
9433
+ if (CreateScatter) {
9476
9434
Value *VectorGep = State.get (getAddr (), Part);
9477
9435
NewSI =
9478
9436
Builder.CreateMaskedScatter (StoredVal, VectorGep, Alignment, Mask);
@@ -9487,6 +9445,45 @@ void VPWidenStoreRecipe::execute(VPTransformState &State) {
9487
9445
}
9488
9446
}
9489
9447
9448
+ void VPWidenVPStoreRecipe::execute (VPTransformState &State) {
9449
+ assert (State.UF == 1 && " Expected only UF == 1 when vectorizing with "
9450
+ " explicit vector length." );
9451
+ // FIXME: Support reverse loading after vp_reverse is added.
9452
+ assert (!isReverse () && " Reverse store are not implemented yet." );
9453
+
9454
+ auto *SI = cast<StoreInst>(&Ingredient);
9455
+
9456
+ VPValue *StoredValue = getStoredValue ();
9457
+ bool CreateScatter = !isConsecutive ();
9458
+ const Align Alignment = getLoadStoreAlignment (&Ingredient);
9459
+
9460
+ auto &Builder = State.Builder ;
9461
+ State.setDebugLocFrom (getDebugLoc ());
9462
+
9463
+ CallInst *NewSI = nullptr ;
9464
+ Value *StoredVal = State.get (StoredValue, 0 );
9465
+ Value *EVL = State.get (getEVL (), VPIteration (0 , 0 ));
9466
+ // FIXME: Support reverse store after vp_reverse is added.
9467
+ Value *Mask =
9468
+ getMask () ? State.get (getMask (), 0 )
9469
+ : Mask = Builder.CreateVectorSplat (State.VF , Builder.getTrue ());
9470
+ Value *Addr = State.get (getAddr (), 0 , !CreateScatter);
9471
+ if (CreateScatter) {
9472
+ NewSI = Builder.CreateIntrinsic (Type::getVoidTy (EVL->getContext ()),
9473
+ Intrinsic::vp_scatter,
9474
+ {StoredVal, Addr, Mask, EVL});
9475
+ } else {
9476
+ VectorBuilder VBuilder (Builder);
9477
+ VBuilder.setEVL (EVL).setMask (Mask);
9478
+ NewSI = cast<CallInst>(VBuilder.createVectorInstruction (
9479
+ Instruction::Store, Type::getVoidTy (EVL->getContext ()),
9480
+ {StoredVal, Addr}));
9481
+ }
9482
+ NewSI->addParamAttr (
9483
+ 1 , Attribute::getWithAlignment (NewSI->getContext (), Alignment));
9484
+
9485
+ State.addMetadata (NewSI, SI);
9486
+ }
9490
9487
// Determine how to lower the scalar epilogue, which depends on 1) optimising
9491
9488
// for minimum code-size, 2) predicate compiler options, 3) loop hints forcing
9492
9489
// predication, and 4) a TTI hook that analyses whether the loop is suitable
0 commit comments