[llvm] [LV] Convert scatter w/uniform addr and mask being header mask to scalar store. (PR #172799)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon May 4 19:51:58 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());
----------------
ElvisWang123 wrote:
Some of the masks from the store recipes is not optimized which requires `simplifyRecipes` to simplify some of the masks.
We can only convert widen store masked by header mask to scalar store. Otherwise we cannot prove the store will actually executed every iteration.
https://github.com/llvm/llvm-project/pull/172799
More information about the llvm-commits
mailing list