[llvm] [VPlan] Replicate VPScalarIVStepsRecipe by VF outside replicate regions. (PR #170053)

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 17 03:50:10 PST 2026


================
@@ -574,12 +580,32 @@ cloneForLane(VPlan &Plan, VPBuilder &Builder, Type *IdxTy,
                                 /*IsSingleScalar=*/true, /*Mask=*/nullptr,
                                 *RepR, *RepR, RepR->getDebugLoc());
   } else {
-    assert(isa<VPInstruction>(DefR) &&
+    assert((isa<VPInstruction, VPScalarIVStepsRecipe>(DefR)) &&
            "DefR must be a VPReplicateRecipe or VPInstruction");
     New = DefR->clone();
     for (const auto &[Idx, Op] : enumerate(NewOps)) {
       New->setOperand(Idx, Op);
     }
+    if (isa<VPScalarIVStepsRecipe>(New)) {
+      if (Lane.getKnownLane() != 0) {
+        VPTypeAnalysis TypeInfo(Plan);
+        Type *BaseIVTy = TypeInfo.inferScalarType(DefR->getOperand(0));
+        Type *IntStepTy = IntegerType::get(BaseIVTy->getContext(),
+                                           BaseIVTy->getScalarSizeInBits());
+        VPBuilder Builder(DefR);
+        VPValue *LaneOffset = Plan.getConstantInt(IdxTy, Lane.getKnownLane());
+        LaneOffset = Builder.createScalarSExtOrTrunc(
+            LaneOffset, IntStepTy, IdxTy, DebugLoc::getUnknown());
+
+        if (New->getNumOperands() == 4) {
----------------
huntergr-arm wrote:

nit: I think the same `getStartIndex()` check would help here too.

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


More information about the llvm-commits mailing list