[llvm] [VPlan] Use DL index type consistently for GEPs (PR #169396)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 26 02:54:08 PST 2025
================
@@ -2593,22 +2593,12 @@ void VPWidenGEPRecipe::printRecipe(raw_ostream &O, const Twine &Indent,
}
#endif
-static Type *getGEPIndexTy(bool IsScalable, bool IsReverse, bool IsUnitStride,
- unsigned CurrentPart, IRBuilderBase &Builder) {
- // Use i32 for the gep index type when the value is constant,
- // or query DataLayout for a more suitable index type otherwise.
- const DataLayout &DL = Builder.GetInsertBlock()->getDataLayout();
- return !IsUnitStride || (IsScalable && (IsReverse || CurrentPart > 0))
- ? DL.getIndexType(Builder.getPtrTy(0))
- : Builder.getInt32Ty();
-}
-
void VPVectorEndPointerRecipe::execute(VPTransformState &State) {
auto &Builder = State.Builder;
unsigned CurrentPart = getUnrollPart(*this);
- bool IsUnitStride = Stride == 1 || Stride == -1;
- Type *IndexTy = getGEPIndexTy(State.VF.isScalable(), /*IsReverse*/ true,
- IsUnitStride, CurrentPart, Builder);
+ Value *Ptr = State.get(getOperand(0), VPLane(0));
+ const DataLayout &DL = Builder.GetInsertBlock()->getDataLayout();
+ Type *IndexTy = DL.getIndexType(Ptr->getType());
----------------
artagnon wrote:
Not sure what you mean? The type inferrence will infer a pointer type for VPVector(End)Recipe, since it just has the pointer operand -- do you mean replacing `Ptr->getType()` with `VPTypeAnalysis(getParent()->getPlan()).inferScalarType(this)`, which would get the live-in IR value's type? Seems worse than using State.get to get the correct Value?
https://github.com/llvm/llvm-project/pull/169396
More information about the llvm-commits
mailing list