[llvm] [VPlan] Model address separately. (PR #72164)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 1 07:17:47 PST 2024


================
@@ -1205,6 +1205,59 @@ void VPWidenGEPRecipe::print(raw_ostream &O, const Twine &Indent,
 }
 #endif
 
+void VPVectorPointerRecipe ::execute(VPTransformState &State) {
+  auto &Builder = State.Builder;
+  State.setDebugLocFrom(getDebugLoc());
+  for (unsigned Part = 0; Part < State.UF; ++Part) {
+    // Calculate the pointer for the specific unroll-part.
+    Value *PartPtr = nullptr;
+    // 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()->getModule()->getDataLayout();
+    Type *IndexTy = State.VF.isScalable() && (IsReverse || Part > 0)
+                        ? DL.getIndexType(IndexedTy->getPointerTo())
+                        : Builder.getInt32Ty();
+    Value *Ptr = State.get(getOperand(0), VPIteration(0, 0));
+    bool InBounds = false;
+    if (auto *GEP = dyn_cast<GetElementPtrInst>(Ptr->stripPointerCasts()))
----------------
ayalz wrote:

nit (unrelated to this patch): should this `if` be an `assert`, must consecutive `Ptr`'s be `GEP`'s, do we risk losing inbound information by retrieving it at code-gen rather than recording it when introducing the recipe.

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


More information about the llvm-commits mailing list