@@ -9417,52 +9417,6 @@ void VPReplicateRecipe::execute(VPTransformState &State) {
9417
9417
State.ILV ->scalarizeInstruction (UI, this , VPIteration (Part, Lane), State);
9418
9418
}
9419
9419
9420
- // / Creates either vp_store or vp_scatter intrinsics calls to represent
9421
- // / predicated store/scatter.
9422
- static Instruction *
9423
- lowerStoreUsingVectorIntrinsics (IRBuilderBase &Builder, Value *Addr,
9424
- Value *StoredVal, bool IsScatter, Value *Mask,
9425
- Value *EVL, const Align &Alignment) {
9426
- CallInst *Call;
9427
- if (IsScatter) {
9428
- Call = Builder.CreateIntrinsic (Type::getVoidTy (EVL->getContext ()),
9429
- Intrinsic::vp_scatter,
9430
- {StoredVal, Addr, Mask, EVL});
9431
- } else {
9432
- VectorBuilder VBuilder (Builder);
9433
- VBuilder.setEVL (EVL).setMask (Mask);
9434
- Call = cast<CallInst>(VBuilder.createVectorInstruction (
9435
- Instruction::Store, Type::getVoidTy (EVL->getContext ()),
9436
- {StoredVal, Addr}));
9437
- }
9438
- Call->addParamAttr (
9439
- 1 , Attribute::getWithAlignment (Call->getContext (), Alignment));
9440
- return Call;
9441
- }
9442
-
9443
- // / Creates either vp_load or vp_gather intrinsics calls to represent
9444
- // / predicated load/gather.
9445
- static Instruction *lowerLoadUsingVectorIntrinsics (IRBuilderBase &Builder,
9446
- VectorType *DataTy,
9447
- Value *Addr, bool IsGather,
9448
- Value *Mask, Value *EVL,
9449
- const Align &Alignment) {
9450
- CallInst *Call;
9451
- if (IsGather) {
9452
- Call =
9453
- Builder.CreateIntrinsic (DataTy, Intrinsic::vp_gather, {Addr, Mask, EVL},
9454
- nullptr , " wide.masked.gather" );
9455
- } else {
9456
- VectorBuilder VBuilder (Builder);
9457
- VBuilder.setEVL (EVL).setMask (Mask);
9458
- Call = cast<CallInst>(VBuilder.createVectorInstruction (
9459
- Instruction::Load, DataTy, Addr, " vp.op.load" ));
9460
- }
9461
- Call->addParamAttr (
9462
- 0 , Attribute::getWithAlignment (Call->getContext (), Alignment));
9463
- return Call;
9464
- }
9465
-
9466
9420
void VPWidenLoadRecipe::execute (VPTransformState &State) {
9467
9421
// Attempt to issue a wide load.
9468
9422
auto *LI = cast<LoadInst>(&Ingredient);
@@ -9491,25 +9445,7 @@ void VPWidenLoadRecipe::execute(VPTransformState &State) {
9491
9445
State.setDebugLocFrom (getDebugLoc ());
9492
9446
for (unsigned Part = 0 ; Part < State.UF ; ++Part) {
9493
9447
Value *NewLI;
9494
- // TODO: split this into several classes for better design.
9495
- if (State.EVL ) {
9496
- assert (State.UF == 1 && " Expected only UF == 1 when vectorizing with "
9497
- " explicit vector length." );
9498
- assert (cast<VPInstruction>(State.EVL )->getOpcode () ==
9499
- VPInstruction::ExplicitVectorLength &&
9500
- " EVL must be VPInstruction::ExplicitVectorLength." );
9501
- Value *EVL = State.get (State.EVL , VPIteration (0 , 0 ));
9502
- // If EVL is not nullptr, then EVL must be a valid value set during plan
9503
- // creation, possibly default value = whole vector register length. EVL
9504
- // is created only if TTI prefers predicated vectorization, thus if EVL
9505
- // is not nullptr it also implies preference for predicated
9506
- // vectorization.
9507
- // FIXME: Support reverse loading after vp_reverse is added.
9508
- Value *MaskPart = IsMaskRequired ? BlockInMaskParts[Part] : nullptr ;
9509
- NewLI = lowerLoadUsingVectorIntrinsics (
9510
- Builder, DataTy, State.get (getAddr (), Part, !CreateGather),
9511
- CreateGather, MaskPart, EVL, Alignment);
9512
- } else if (CreateGather) {
9448
+ if (CreateGather) {
9513
9449
Value *MaskPart = IsMaskRequired ? BlockInMaskParts[Part] : nullptr ;
9514
9450
Value *VectorGep = State.get (getAddr (), Part);
9515
9451
NewLI = Builder.CreateMaskedGather (DataTy, VectorGep, Alignment, MaskPart,
@@ -9535,6 +9471,51 @@ void VPWidenLoadRecipe::execute(VPTransformState &State) {
9535
9471
}
9536
9472
}
9537
9473
9474
+ void VPWidenVPLoadRecipe::execute (VPTransformState &State) {
9475
+ assert (State.UF == 1 && " Expected only UF == 1 when vectorizing with "
9476
+ " explicit vector length." );
9477
+ // FIXME: Support reverse loading after vp_reverse is added.
9478
+ assert (!isReverse () && " Reverse loads are not implemented yet." );
9479
+
9480
+ // Attempt to issue a wide load.
9481
+ auto *LI = cast<LoadInst>(&Ingredient);
9482
+
9483
+ Type *ScalarDataTy = getLoadStoreType (&Ingredient);
9484
+ auto *DataTy = VectorType::get (ScalarDataTy, State.VF );
9485
+ const Align Alignment = getLoadStoreAlignment (&Ingredient);
9486
+ bool CreateGather = !isConsecutive ();
9487
+
9488
+ auto &Builder = State.Builder ;
9489
+ // Handle loads.
9490
+ assert (LI && " Must have a load instruction" );
9491
+ State.setDebugLocFrom (getDebugLoc ());
9492
+ for (unsigned Part = 0 ; Part < State.UF ; ++Part) {
9493
+ CallInst *NewLI;
9494
+ Value *EVL = State.get (getEVL (), VPIteration (0 , 0 ));
9495
+ Value *Addr = State.get (getAddr (), Part, !CreateGather);
9496
+ Value *Mask =
9497
+ getMask ()
9498
+ ? State.get (getMask (), Part)
9499
+ : Mask = Builder.CreateVectorSplat (State.VF , Builder.getTrue ());
9500
+ if (CreateGather) {
9501
+ NewLI = Builder.CreateIntrinsic (DataTy, Intrinsic::vp_gather,
9502
+ {Addr, Mask, EVL}, nullptr ,
9503
+ " wide.masked.gather" );
9504
+ } else {
9505
+ VectorBuilder VBuilder (Builder);
9506
+ VBuilder.setEVL (EVL).setMask (Mask);
9507
+ NewLI = cast<CallInst>(VBuilder.createVectorInstruction (
9508
+ Instruction::Load, DataTy, Addr, " vp.op.load" ));
9509
+ }
9510
+ NewLI->addParamAttr (
9511
+ 0 , Attribute::getWithAlignment (NewLI->getContext (), Alignment));
9512
+
9513
+ // Add metadata to the load.
9514
+ State.addMetadata (NewLI, LI);
9515
+ State.set (this , NewLI, Part);
9516
+ }
9517
+ }
9518
+
9538
9519
void VPWidenStoreRecipe::execute (VPTransformState &State) {
9539
9520
auto *SI = cast<StoreInst>(&Ingredient);
9540
9521
@@ -9562,24 +9543,7 @@ void VPWidenStoreRecipe::execute(VPTransformState &State) {
9562
9543
Instruction *NewSI = nullptr ;
9563
9544
Value *StoredVal = State.get (StoredValue, Part);
9564
9545
// TODO: split this into several classes for better design.
9565
- if (State.EVL ) {
9566
- assert (State.UF == 1 && " Expected only UF == 1 when vectorizing with "
9567
- " explicit vector length." );
9568
- assert (cast<VPInstruction>(State.EVL )->getOpcode () ==
9569
- VPInstruction::ExplicitVectorLength &&
9570
- " EVL must be VPInstruction::ExplicitVectorLength." );
9571
- Value *EVL = State.get (State.EVL , VPIteration (0 , 0 ));
9572
- // If EVL is not nullptr, then EVL must be a valid value set during plan
9573
- // creation, possibly default value = whole vector register length. EVL
9574
- // is created only if TTI prefers predicated vectorization, thus if EVL
9575
- // is not nullptr it also implies preference for predicated
9576
- // vectorization.
9577
- // FIXME: Support reverse store after vp_reverse is added.
9578
- Value *MaskPart = IsMaskRequired ? BlockInMaskParts[Part] : nullptr ;
9579
- NewSI = lowerStoreUsingVectorIntrinsics (
9580
- Builder, State.get (getAddr (), Part, !CreateScatter), StoredVal,
9581
- CreateScatter, MaskPart, EVL, Alignment);
9582
- } else if (CreateScatter) {
9546
+ if (CreateScatter) {
9583
9547
Value *MaskPart = IsMaskRequired ? BlockInMaskParts[Part] : nullptr ;
9584
9548
Value *VectorGep = State.get (getAddr (), Part);
9585
9549
NewSI = Builder.CreateMaskedScatter (StoredVal, VectorGep, Alignment,
@@ -9603,6 +9567,48 @@ void VPWidenStoreRecipe::execute(VPTransformState &State) {
9603
9567
}
9604
9568
}
9605
9569
9570
+ void VPWidenVPStoreRecipe::execute (VPTransformState &State) {
9571
+ assert (State.UF == 1 && " Expected only UF == 1 when vectorizing with "
9572
+ " explicit vector length." );
9573
+ // FIXME: Support reverse loading after vp_reverse is added.
9574
+ assert (!isReverse () && " Reverse store are not implemented yet." );
9575
+
9576
+ auto *SI = cast<StoreInst>(&Ingredient);
9577
+
9578
+ VPValue *StoredValue = getStoredValue ();
9579
+ bool CreateScatter = !isConsecutive ();
9580
+ const Align Alignment = getLoadStoreAlignment (&Ingredient);
9581
+
9582
+ auto &Builder = State.Builder ;
9583
+ State.setDebugLocFrom (getDebugLoc ());
9584
+
9585
+ for (unsigned Part = 0 ; Part < State.UF ; ++Part) {
9586
+ CallInst *NewSI = nullptr ;
9587
+ Value *StoredVal = State.get (StoredValue, Part);
9588
+ Value *EVL = State.get (getEVL (), VPIteration (0 , 0 ));
9589
+ // FIXME: Support reverse store after vp_reverse is added.
9590
+ Value *Mask =
9591
+ getMask ()
9592
+ ? State.get (getMask (), Part)
9593
+ : Mask = Builder.CreateVectorSplat (State.VF , Builder.getTrue ());
9594
+ Value *Addr = State.get (getAddr (), Part, !CreateScatter);
9595
+ if (CreateScatter) {
9596
+ NewSI = Builder.CreateIntrinsic (Type::getVoidTy (EVL->getContext ()),
9597
+ Intrinsic::vp_scatter,
9598
+ {StoredVal, Addr, Mask, EVL});
9599
+ } else {
9600
+ VectorBuilder VBuilder (Builder);
9601
+ VBuilder.setEVL (EVL).setMask (Mask);
9602
+ NewSI = cast<CallInst>(VBuilder.createVectorInstruction (
9603
+ Instruction::Store, Type::getVoidTy (EVL->getContext ()),
9604
+ {StoredVal, Addr}));
9605
+ }
9606
+ NewSI->addParamAttr (
9607
+ 1 , Attribute::getWithAlignment (NewSI->getContext (), Alignment));
9608
+
9609
+ State.addMetadata (NewSI, SI);
9610
+ }
9611
+ }
9606
9612
// Determine how to lower the scalar epilogue, which depends on 1) optimising
9607
9613
// for minimum code-size, 2) predicate compiler options, 3) loop hints forcing
9608
9614
// predication, and 4) a TTI hook that analyses whether the loop is suitable
0 commit comments