[llvm] [LV] Convert scatter w/uniform addr and mask being header mask to scalar store. (PR #172799)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 23:34:15 PDT 2026


================
@@ -7676,19 +7676,32 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
     VFRange SubRange = {VF, MaxVFTimes2};
     if (auto Plan = tryToBuildVPlanWithVPRecipes(
             std::unique_ptr<VPlan>(VPlan0->duplicate()), SubRange, &LVer)) {
+      // Add the start VF to prevent optimizations on plan with scalar VF.
+      Plan->addVF(SubRange.Start);
+      Plan->setName("Initial VPlan");
+
       // Now optimize the initial VPlan.
       VPlanTransforms::hoistPredicatedLoads(*Plan, PSE, OrigLoop);
       VPlanTransforms::sinkPredicatedStores(*Plan, PSE, OrigLoop);
       RUN_VPLAN_PASS(VPlanTransforms::truncateToMinimalBitwidths, *Plan,
                      CM.getMinimalBitwidths());
       RUN_VPLAN_PASS(VPlanTransforms::optimize, *Plan);
+      VPCostContext CostCtx(CM.TTI, *CM.TLI, *Plan, CM, CM.CostKind, CM.PSE,
+                            OrigLoop);
+      // TODO: Try to put narrowScatters in VPlanTransforms::optimize
+      RUN_VPLAN_PASS(VPlanTransforms::narrowScatters, *Plan, CostCtx, SubRange,
+                     CM.foldTailWithEVL());
----------------
artagnon wrote:

Any idea why? Which additional transforms cause the additional simplifications?

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


More information about the llvm-commits mailing list