[llvm] [VPlan] Dissolve replicate regions with vector live-outs. (PR #189022)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 03:56:28 PDT 2026


================
@@ -785,10 +804,45 @@ static void dissolveReplicateRegion(VPRegionBlock *Region, ElementCount VF,
   // single-scalar.
   convertRecipesInRegionBlocksToSingleScalar(Plan, IdxTy, FirstLaneEntry, VF);
 
+  // For scalar VF, just wire the blocks and return; no cloning or packing
+  // needed.
+  if (VF.isScalar()) {
+    VPBlockUtils::connectBlocks(Predecessor, FirstLaneEntry);
+    VPBlockUtils::connectBlocks(FirstLaneExiting, Successor);
+    return;
+  }
+
+  // Create a BuildVector or BuildStructVector in successor block for every
+  // VPPhi in (first lane's) exiting block having vector uses. All their
+  // operands are initialized to poison and will be replaced when processing
+  // each clone, except for the operand of the first lane which set here.
+  // BuildVectors are recorded to be replaced later by chains of insert-element
+  // and widen phi's.
+  unsigned NumLanes = VF.getFixedValue();
+  VPTypeAnalysis TypeInfo(Plan);
+  SmallVector<VPInstruction *> BuildVectors;
+  for (auto &R : FirstLaneExiting->phis()) {
+    auto *Phi = cast<VPPhi>(&R);
+    if (vputils::onlyFirstLaneUsed(Phi))
+      continue;
----------------
fhahn wrote:

Yep

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


More information about the llvm-commits mailing list