[llvm] [VPlan] Scalarize to first-lane-only directly on VPlan (PR #184267)

Andrei Elovikov via llvm-commits llvm-commits at lists.llvm.org
Mon May 4 09:27:53 PDT 2026


================
@@ -6405,3 +6405,52 @@ void VPlanTransforms::makeMemOpWideningDecisions(
     ReplaceWith(Recipe);
   }
 }
+
+void VPlanTransforms::makeScalarizationDecisions(VPlan &Plan, VFRange &Range) {
+  if (LoopVectorizationPlanner::getDecisionAndClampRange(
+          [&](ElementCount VF) { return VF.isScalar(); }, Range))
+    return;
+
+  PostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> POT(
+      Plan.getEntry());
+  for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(POT)) {
+    for (VPRecipeBase &R : make_early_inc_range(reverse(*VPBB))) {
+      auto *VPI = dyn_cast<VPInstruction>(&R);
+      if (!VPI)
----------------
eas wrote:

I think this part is very subjective/nit and I'd prefer to keep separate statements unless you really insist.

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


More information about the llvm-commits mailing list