[llvm] [VPlan] Directly unroll VectorPointerRecipe (PR #168886)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 4 09:16:11 PST 2025


================
@@ -2504,15 +2504,12 @@ void VPVectorEndPointerRecipe::printRecipe(raw_ostream &O, const Twine &Indent,
 
 void VPVectorPointerRecipe::execute(VPTransformState &State) {
   auto &Builder = State.Builder;
-  unsigned CurrentPart = getUnrollPart(*this);
-  const DataLayout &DL = Builder.GetInsertBlock()->getDataLayout();
-  Type *IndexTy = DL.getIndexType(State.TypeAnalysis.inferScalarType(this));
   Value *Ptr = State.get(getOperand(0), VPLane(0));
-
-  Value *Increment = createStepForVF(Builder, IndexTy, State.VF, CurrentPart);
-  Value *ResultPtr = Builder.CreateGEP(getSourceElementType(), Ptr, Increment,
-                                       "", getGEPNoWrapFlags());
-
+  if (!getOffset())
+    return State.set(this, Ptr, /*IsScalar*/ true);
+  Value *Offset = State.get(getOffset(), true);
+  Value *ResultPtr = Builder.CreateGEP(getSourceElementType(), Ptr, Offset, "",
+                                       getGEPNoWrapFlags());
----------------
artagnon wrote:

You mean creating a `GEP Ptr, 0` when there is no offset, and handling it in simplifyRecipe? Wouldn't that create more complication including fetching the DL, creating an index type, and creating the zero constant, and adding the fold? Can you clarify what the advantage of that would be?

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


More information about the llvm-commits mailing list