@@ -544,7 +544,8 @@ class InnerLoopVectorizer {
544
544
// / vectorized loop.
545
545
void vectorizeMemoryInstruction (Instruction *Instr, VPTransformState &State,
546
546
VPValue *Def, VPValue *Addr,
547
- VPValue *StoredValue, VPValue *BlockInMask);
547
+ VPValue *StoredValue, VPValue *BlockInMask,
548
+ bool ConsecutiveStride, bool Reverse);
548
549
549
550
// / Set the debug location in the builder \p Ptr using the debug location in
550
551
// / \p V. If \p Ptr is None then it uses the class member's Builder.
@@ -2900,7 +2901,8 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup(
2900
2901
2901
2902
void InnerLoopVectorizer::vectorizeMemoryInstruction (
2902
2903
Instruction *Instr, VPTransformState &State, VPValue *Def, VPValue *Addr,
2903
- VPValue *StoredValue, VPValue *BlockInMask) {
2904
+ VPValue *StoredValue, VPValue *BlockInMask, bool ConsecutiveStride,
2905
+ bool Reverse) {
2904
2906
// Attempt to issue a wide load.
2905
2907
LoadInst *LI = dyn_cast<LoadInst>(Instr);
2906
2908
StoreInst *SI = dyn_cast<StoreInst>(Instr);
@@ -2909,31 +2911,11 @@ void InnerLoopVectorizer::vectorizeMemoryInstruction(
2909
2911
assert ((!SI || StoredValue) && " No stored value provided for widened store" );
2910
2912
assert ((!LI || !StoredValue) && " Stored value provided for widened load" );
2911
2913
2912
- LoopVectorizationCostModel::InstWidening Decision =
2913
- Cost->getWideningDecision (Instr, VF);
2914
- assert ((Decision == LoopVectorizationCostModel::CM_Widen ||
2915
- Decision == LoopVectorizationCostModel::CM_Widen_Reverse ||
2916
- Decision == LoopVectorizationCostModel::CM_GatherScatter) &&
2917
- " CM decision is not to widen the memory instruction" );
2918
-
2919
2914
Type *ScalarDataTy = getLoadStoreType (Instr);
2920
2915
2921
2916
auto *DataTy = VectorType::get (ScalarDataTy, VF);
2922
2917
const Align Alignment = getLoadStoreAlignment (Instr);
2923
-
2924
- // Determine if the pointer operand of the access is either consecutive or
2925
- // reverse consecutive.
2926
- bool Reverse = (Decision == LoopVectorizationCostModel::CM_Widen_Reverse);
2927
- bool ConsecutiveStride =
2928
- Reverse || (Decision == LoopVectorizationCostModel::CM_Widen);
2929
- bool CreateGatherScatter =
2930
- (Decision == LoopVectorizationCostModel::CM_GatherScatter);
2931
-
2932
- // Either Ptr feeds a vector load/store, or a vector GEP should feed a vector
2933
- // gather/scatter. Otherwise Decision should have been to Scalarize.
2934
- assert ((ConsecutiveStride || CreateGatherScatter) &&
2935
- " The instruction should be scalarized" );
2936
- (void )ConsecutiveStride;
2918
+ bool CreateGatherScatter = !ConsecutiveStride;
2937
2919
2938
2920
VectorParts BlockInMaskParts (UF);
2939
2921
bool isMaskRequired = BlockInMask;
@@ -8808,12 +8790,21 @@ VPRecipeBase *VPRecipeBuilder::tryToWidenMemory(Instruction *I,
8808
8790
if (Legal->isMaskRequired (I))
8809
8791
Mask = createBlockInMask (I->getParent (), Plan);
8810
8792
8793
+ // Determine if the pointer operand of the access is either consecutive or
8794
+ // reverse consecutive.
8795
+ LoopVectorizationCostModel::InstWidening Decision =
8796
+ CM.getWideningDecision (I, Range.Start );
8797
+ bool Reverse = Decision == LoopVectorizationCostModel::CM_Widen_Reverse;
8798
+ bool Consecutive =
8799
+ Reverse || Decision == LoopVectorizationCostModel::CM_Widen;
8800
+
8811
8801
if (LoadInst *Load = dyn_cast<LoadInst>(I))
8812
- return new VPWidenMemoryInstructionRecipe (*Load, Operands[0 ], Mask);
8802
+ return new VPWidenMemoryInstructionRecipe (*Load, Operands[0 ], Mask,
8803
+ Consecutive, Reverse);
8813
8804
8814
8805
StoreInst *Store = cast<StoreInst>(I);
8815
8806
return new VPWidenMemoryInstructionRecipe (*Store, Operands[1 ], Operands[0 ],
8816
- Mask);
8807
+ Mask, Consecutive, Reverse );
8817
8808
}
8818
8809
8819
8810
VPWidenIntOrFpInductionRecipe *
@@ -9912,7 +9903,7 @@ void VPWidenMemoryInstructionRecipe::execute(VPTransformState &State) {
9912
9903
VPValue *StoredValue = isStore () ? getStoredValue () : nullptr ;
9913
9904
State.ILV ->vectorizeMemoryInstruction (
9914
9905
&Ingredient, State, StoredValue ? nullptr : getVPSingleValue (), getAddr (),
9915
- StoredValue, getMask ());
9906
+ StoredValue, getMask (), Consecutive, Reverse );
9916
9907
}
9917
9908
9918
9909
// Determine how to lower the scalar epilogue, which depends on 1) optimising
0 commit comments