[llvm] [LV] Use index type for base pointer computation in convertToStridedAccesses (PR #201070)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 4 01:18:14 PDT 2026


================
@@ -7023,17 +7023,19 @@ 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.getOrAddLiveIn(Step->getValue());
       Type *IndexTy = Plan.getDataLayout().getIndexType(Ptr->getScalarType());
       assert(IndexTy == StrideInBytes->getScalarType() &&
              "Stride type from SCEV must match the index type");
-      VPValue *CanIVTyStride = Builder.createScalarSExtOrTrunc(
-          StrideInBytes, VectorLoop->getCanonicalIVType(), IndexTy,
-          DebugLoc::getUnknown());
+      VPValue *CanIV = Builder.createScalarSExtOrTrunc(
+          VectorLoop->getCanonicalIV(), IndexTy,
+          VectorLoop->getCanonicalIVType(), DebugLoc::getUnknown());
----------------
Mel-Chen wrote:

GEP indices are always sign-extended or truncated to the index type prior to pointer computation. And, multiply first then truncate, or truncate first then multiply, the final truncated value is identical.
https://alive2.llvm.org/ce/z/fBCZq9

https://github.com/llvm/llvm-project/pull/201070


More information about the llvm-commits mailing list