[llvm-branch-commits] [llvm] [VPlan] Explicitly handle scalar pointer inductions. (PR #80273)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Feb 5 07:31:44 PST 2024


================
@@ -489,6 +490,23 @@ Value *VPInstruction::generateInstruction(VPTransformState &State,
 
     return ReducedPartRdx;
   }
+  case VPInstruction::PtrAdd: {
+    if (vputils::onlyFirstLaneUsed(this)) {
+      auto *P = Builder.CreatePtrAdd(
+          State.get(getOperand(0), VPIteration(Part, 0)),
+          State.get(getOperand(1), VPIteration(Part, 0)), Name);
+      State.set(this, P, VPIteration(Part, 0));
+    } else {
+      for (unsigned Lane = 0; Lane != State.VF.getKnownMinValue(); ++Lane) {
+        Value *P = Builder.CreatePtrAdd(
+            State.get(getOperand(0), VPIteration(Part, Lane)),
+            State.get(getOperand(1), VPIteration(Part, Lane)), Name);
+
+        State.set(this, P, VPIteration(Part, Lane));
+      }
+    }
+    return nullptr;
----------------
ayalz wrote:

Better for generateInstruction() to continue generate and return a single per-part Value, which is then set in State, possibly renaming it generateValuePerPart(), and have a separate generateValuePerLane() - currently to be invoked only for PtrAdd having all lanes used?

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


More information about the llvm-branch-commits mailing list