@@ -3621,9 +3621,9 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {
36213621 if (IsUniformMemOpUse (I))
36223622 return true ;
36233623
3624- return (WideningDecision == CM_Widen ||
3625- WideningDecision == CM_Widen_Reverse ||
3626- WideningDecision == CM_Interleave);
3624+ return (
3625+ WideningDecision == CM_Widen || WideningDecision == CM_Widen_Reverse ||
3626+ WideningDecision == CM_Strided || WideningDecision == CM_Interleave);
36273627 };
36283628
36293629 // Returns true if Ptr is the pointer operand of a memory access instruction
@@ -8367,17 +8367,27 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
83678367 // reverse consecutive.
83688368 LoopVectorizationCostModel::InstWidening Decision =
83698369 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+
83708379 bool Reverse = Decision == LoopVectorizationCostModel::CM_Widen_Reverse;
83718380 bool Consecutive =
83728381 Reverse || Decision == LoopVectorizationCostModel::CM_Widen;
83738382 bool Strided = Decision == LoopVectorizationCostModel::CM_Strided;
83748383
83758384 VPValue *Ptr = isa<LoadInst>(I) ? Operands[0 ] : Operands[1 ];
8376- if (Consecutive) {
8385+ if (Consecutive || Strided ) {
83778386 auto *GEP = dyn_cast<GetElementPtrInst>(
83788387 Ptr->getUnderlyingValue ()->stripPointerCasts ());
83798388 VPSingleDefRecipe *VectorPtr;
83808389 if (Reverse) {
8390+ assert (!Strided && " Reverse and Strided are mutually exclusive." );
83818391 // When folding the tail, we may compute an address that we don't in the
83828392 // original scalar loop and it may not be inbounds. Drop Inbounds in that
83838393 // case.
@@ -8388,7 +8398,7 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
83888398 VectorPtr = new VPReverseVectorPointerRecipe (
83898399 Ptr, &Plan.getVF (), getLoadStoreType (I), Flags, I->getDebugLoc ());
83908400 } else {
8391- VectorPtr = new VPVectorPointerRecipe (Ptr, getLoadStoreType (I),
8401+ VectorPtr = new VPVectorPointerRecipe (Ptr, getLoadStoreType (I), Strided,
83928402 GEP ? GEP->getNoWrapFlags ()
83938403 : GEPNoWrapFlags::none (),
83948404 I->getDebugLoc ());
0 commit comments