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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 05:26:07 PDT 2026


================
@@ -807,6 +860,31 @@ static void dissolveReplicateRegion(VPRegionBlock *Region, ElementCount VF,
   // FirstLaneExiting.
   VPBlockUtils::connectBlocks(Predecessor, FirstLaneEntry);
   VPBlockUtils::connectBlocks(FirstLaneExiting, NextLaneEntry);
+
+  // Fold BuildVector fed by scalar phis into VPWidenPHIRecipes with
+  // InsertElement per lane.
+  // TODO: check if this folding should be dropped.
+  for (VPInstruction *BV : BuildVectors) {
+    assert(BV->getNumOperands() == NumLanes &&
+           "BuildVector must have one operand per lane");
+    for (const auto &[Idx, Op] : enumerate(BV->operands())) {
+      auto *ScalarPhi = cast<VPPhi>(Op);
+      auto DL = ScalarPhi->getDebugLoc();
+      auto *PredOp = cast<VPSingleDefRecipe>(ScalarPhi->getOperand(1));
+      VPValue *Poison = ScalarPhi->getOperand(0);
+      VPValue *PrevVal = Idx == 0 ? Poison : BV->getOperand(Idx - 1);
----------------
fhahn wrote:

Ah yes, updated after recent changes

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


More information about the llvm-commits mailing list