[llvm] [VPlan][NFC] Decide consecutive mem-op predication from VPlan masks. (PR #215537)
Madhur Amilkanthwar via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 11 05:22:07 PDT 2026
https://github.com/madhur13490 created https://github.com/llvm/llvm-project/pull/215537
Use the mask attached by VPlanPredicator instead of the legacy isPredicatedInst cost-model query when widening consecutive loads and stores.
>From 76043249289ccdd8132fefc92d40b81cbfb307db Mon Sep 17 00:00:00 2001
From: Madhur Amilkanthwar <madhura at nvidia.com>
Date: Tue, 11 Aug 2026 04:46:10 -0700
Subject: [PATCH] [VPlan] Decide consecutive mem-op predication from VPlan
masks.
Use the mask attached by VPlanPredicator instead of the legacy
isPredicatedInst cost-model query when widening consecutive loads
and stores.
---
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index 5f125aecb005a..ce28056ba470b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -5456,7 +5456,8 @@ void VPlanTransforms::makeMemOpWideningDecisions(VPlan &Plan, VFRange &Range,
"makeVPlanMemOpDecision", ProcessSubset, Plan, [&](VPInstruction *VPI) {
Instruction *I = VPI->getUnderlyingInstr();
bool IsLoad = VPI->getOpcode() == Instruction::Load;
- if (RecipeBuilder.isPredicatedInst(I) || !IsLoad ||
+ // Skip accesses that already carry a mask from VPlanPredicator.
+ if (VPI->isMasked() || !IsLoad ||
!vputils::isUsedByLoadStoreAddress(VPI))
return false;
@@ -5495,9 +5496,9 @@ void VPlanTransforms::makeMemOpWideningDecisions(VPlan &Plan, VFRange &Range,
bool Reverse = Stride == -1;
// A predicated access can only be widened (rather than scalarized) if
- // the target supports a masked load/store for it.
- // TODO: Determine if a load/store needs predication directly in VPlan.
- bool IsPredicated = RecipeBuilder.isPredicatedInst(I);
+ // the target supports a masked load/store for it. Use the mask
+ // attached by VPlanPredicator instead of the legacy CM query.
+ bool IsPredicated = VPI->isMasked();
if (IsPredicated && !CostCtx.Config.isLegalMaskedLoadOrStore(
IsLoad, ScalarTy, getLoadStoreAlignment(I),
getLoadStoreAddressSpace(I)))
More information about the llvm-commits
mailing list