@@ -3627,9 +3627,9 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
3627
3627
if (IsUniformMemOpUse (I))
3628
3628
return true ;
3629
3629
3630
- return (WideningDecision == CM_Widen ||
3631
- WideningDecision == CM_Widen_Reverse ||
3632
- WideningDecision == CM_Interleave);
3630
+ return (
3631
+ WideningDecision == CM_Widen || WideningDecision == CM_Widen_Reverse ||
3632
+ WideningDecision == CM_Strided || WideningDecision == CM_Interleave);
3633
3633
};
3634
3634
3635
3635
// Returns true if Ptr is the pointer operand of a memory access instruction
@@ -8367,17 +8367,27 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
8367
8367
// reverse consecutive.
8368
8368
LoopVectorizationCostModel::InstWidening Decision =
8369
8369
CM.getWideningDecision (I, Range.Start );
8370
+
8371
+ auto SameWiden = [&](ElementCount VF) -> bool {
8372
+ return Decision == CM.getWideningDecision (I, VF);
8373
+ };
8374
+ bool ContainsWidenVF =
8375
+ LoopVectorizationPlanner::getDecisionAndClampRange (SameWiden, Range);
8376
+ assert (ContainsWidenVF &&
8377
+ " At least widen the memory accesses by the Start VF." );
8378
+
8370
8379
bool Reverse = Decision == LoopVectorizationCostModel::CM_Widen_Reverse;
8371
8380
bool Consecutive =
8372
8381
Reverse || Decision == LoopVectorizationCostModel::CM_Widen;
8373
8382
bool Strided = Decision == LoopVectorizationCostModel::CM_Strided;
8374
8383
8375
8384
VPValue *Ptr = isa<LoadInst>(I) ? Operands[0 ] : Operands[1 ];
8376
- if (Consecutive) {
8385
+ if (Consecutive || Strided ) {
8377
8386
auto *GEP = dyn_cast<GetElementPtrInst>(
8378
8387
Ptr->getUnderlyingValue ()->stripPointerCasts ());
8379
8388
VPSingleDefRecipe *VectorPtr;
8380
8389
if (Reverse) {
8390
+ assert (!Strided && " Reverse and Strided are mutually exclusive." );
8381
8391
// When folding the tail, we may compute an address that we don't in the
8382
8392
// original scalar loop and it may not be inbounds. Drop Inbounds in that
8383
8393
// case.
@@ -8388,7 +8398,7 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
8388
8398
VectorPtr = new VPReverseVectorPointerRecipe (
8389
8399
Ptr, &Plan.getVF (), getLoadStoreType (I), Flags, I->getDebugLoc ());
8390
8400
} else {
8391
- VectorPtr = new VPVectorPointerRecipe (Ptr, getLoadStoreType (I),
8401
+ VectorPtr = new VPVectorPointerRecipe (Ptr, getLoadStoreType (I), Strided,
8392
8402
GEP ? GEP->getNoWrapFlags ()
8393
8403
: GEPNoWrapFlags::none (),
8394
8404
I->getDebugLoc ());
0 commit comments