[llvm] [VPlan] Use pointer index type for stride in convertToStridedAccesses (PR #199647)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 1 02:09:13 PDT 2026
================
@@ -7030,13 +7031,20 @@ void VPlanTransforms::convertToStridedAccesses(VPlan &Plan,
VPBuilder Builder(LoadR);
// Create the base pointer of strided access.
+ // TODO: reuse VPDerivedIVRecipe for base pointer computation when it
+ // supports a general VPValue as the start value.
VPValue *StartVPV = vputils::getOrCreateVPValueForSCEVExpr(Plan, Start);
- VPValue *StrideInBytes =
- Plan.getConstantInt(VectorLoop->getCanonicalIVType(),
- Step->getSExtValue(), /*IsSigned=*/true);
+ VPValue *StrideInBytes = Plan.getOrAddLiveIn(Step->getValue());
+ Type *StrideTy = TypeInfo.inferScalarType(StrideInBytes);
+ assert(StrideTy == PSE.getSE()->getDataLayout().getIndexType(
+ TypeInfo.inferScalarType(Ptr)) &&
+ "Stride type from SCEV must match the index type");
+ VPValue *CanIV = Builder.createScalarZExtOrTrunc(
----------------
Mel-Chen wrote:
I've also considered this point, especially since `VPDerivedIVRecipe` uses `sext` rather than `zext`. However, a canonical IV is a non-negative integer I think. If the canonical IV gets large enough in some iteration to have its most significant bit set to 1, using sext would treat it as a negative number, yielding a completely different value than what was intended. Or is there an implicit guarantee that a canonical IV's most significant bit will never be 1, making this a non-issue?
https://github.com/llvm/llvm-project/pull/199647
More information about the llvm-commits
mailing list