[llvm] [VPlan] Use pointer index type for stride in convertToStridedAccesses (PR #199647)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Thu May 28 03:01:37 PDT 2026
================
@@ -6912,12 +6895,16 @@ void VPlanTransforms::convertToStridedAccesses(VPlan &Plan,
VPBuilder Builder(LoadR);
// Create the base pointer of strided access.
VPValue *StartVPV = vputils::getOrCreateVPValueForSCEVExpr(Plan, Start);
+ const DataLayout &DL = PSE.getSE()->getDataLayout();
+ Type *IdxTy = DL.getIndexType(TypeInfo.inferScalarType(Ptr));
VPValue *StrideInBytes =
- Plan.getConstantInt(VectorLoop->getCanonicalIVType(),
- Step->getSExtValue(), /*IsSigned=*/true);
+ Plan.getConstantInt(IdxTy, Step->getSExtValue(), /*IsSigned=*/true);
auto *AddRecPtr = cast<SCEVAddRecExpr>(PtrSCEV);
+ VPValue *CanIV = Builder.createScalarZExtOrTrunc(
+ VectorLoop->getCanonicalIV(), IdxTy, VectorLoop->getCanonicalIVType(),
+ DebugLoc::getUnknown());
auto *Offset = Builder.createOverflowingOp(
- Instruction::Mul, {VectorLoop->getCanonicalIV(), StrideInBytes},
+ Instruction::Mul, {CanIV, StrideInBytes},
----------------
lukel97 wrote:
IIUC every offset should correspond to an address from the original vp.gather. So if the canIV is very large then wouldn't the gather addresses have overflowed anyway?
https://github.com/llvm/llvm-project/pull/199647
More information about the llvm-commits
mailing list