[llvm] 52feb1f - [NFC][VPlan] Move `introduceMasksAndLinearize` into a `VPPredicator`'s method (#217483)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 9 09:47:57 PDT 2026
Author: Andrei Elovikov
Date: 2026-09-09T16:47:49Z
New Revision: 52feb1fe499914ef1d7669fa75ab46e12b1a37dd
URL: https://github.com/llvm/llvm-project/commit/52feb1fe499914ef1d7669fa75ab46e12b1a37dd
DIFF: https://github.com/llvm/llvm-project/commit/52feb1fe499914ef1d7669fa75ab46e12b1a37dd.diff
LOG: [NFC][VPlan] Move `introduceMasksAndLinearize` into a `VPPredicator`'s method (#217483)
To reduce diff in the next PRs.
AI-assisted.
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp b/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
index e056b2b613b33..85ef7ad4459d7 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp
@@ -25,6 +25,8 @@ using namespace VPlanPatternMatch;
namespace {
class VPPredicator {
+ VPlan &Plan;
+
/// Builder to construct recipes to compute masks.
VPBuilder Builder;
@@ -92,7 +94,8 @@ class VPPredicator {
VPValue *createBlendMaskForEdges(ArrayRef<EdgeTy> Edges, VPBasicBlock *VPBB);
public:
- VPPredicator(VPlan &Plan) : VPDT(Plan), VPPDT(Plan), VPPDF(VPPDT) {}
+ VPPredicator(VPlan &Plan)
+ : Plan(Plan), VPDT(Plan), VPPDT(Plan), VPPDF(VPPDT) {}
/// Returns the *entry* mask for \p VPBB.
VPValue *getBlockInMask(const VPBasicBlock *VPBB) const {
@@ -109,6 +112,9 @@ class VPPredicator {
/// Convert phi recipes in \p VPBB to VPBlendRecipes.
void convertPhisToBlends(VPBasicBlock *VPBB);
+
+ /// Predicate and linearize the plan.
+ void run();
};
} // namespace
@@ -394,14 +400,10 @@ void VPPredicator::convertPhisToBlends(VPBasicBlock *VPBB) {
}
}
-void VPlanTransforms::introduceMasksAndLinearize(VPlan &Plan) {
- // Nested loop regions (outer-loop vectorization) are not supported yet.
- if (Plan.isOuterLoop())
- return;
- VPRegionBlock *LoopRegion = Plan.getVectorLoopRegion();
- // Scan the body of the loop in a topological order to visit each basic block
- // after having visited its predecessor basic blocks.
- VPBasicBlock *Header = LoopRegion->getEntryBasicBlock();
+void VPPredicator::run() {
+ VPBasicBlock *Header = Plan.getVectorLoopRegion()->getEntryBasicBlock();
+ // Scan the body of the loop in a topological order to visit each basic
+ // block after having visited its predecessor basic blocks.
ReversePostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> RPOT(
Header);
// Non-outer regions with VPBBs only are supported at the moment.
@@ -409,15 +411,14 @@ void VPlanTransforms::introduceMasksAndLinearize(VPlan &Plan) {
DenseMap<const VPBasicBlock *, std::optional<VPExecutionFrequency>>
Frequencies = vputils::computeExecutionFrequencies(Blocks);
- VPPredicator Predicator(Plan);
for (VPBasicBlock *VPBB : Blocks) {
// Introduce the mask for VPBB, which may introduce needed edge masks, and
// convert all phi recipes of VPBB to blend recipes unless VPBB is the
// header.
if (VPBB != Header)
- Predicator.createBlockInMask(VPBB);
+ createBlockInMask(VPBB);
- VPValue *BlockMask = Predicator.getBlockInMask(VPBB);
+ VPValue *BlockMask = getBlockInMask(VPBB);
if (!BlockMask)
continue;
@@ -436,7 +437,7 @@ void VPlanTransforms::introduceMasksAndLinearize(VPlan &Plan) {
for (VPBasicBlock *VPBB : reverse(Blocks))
if (VPBB != Header)
- Predicator.convertPhisToBlends(VPBB);
+ convertPhisToBlends(VPBB);
// Linearize the blocks of the loop into one serial chain.
VPBlockBase *PrevVPBB = nullptr;
@@ -455,3 +456,10 @@ void VPlanTransforms::introduceMasksAndLinearize(VPlan &Plan) {
PrevVPBB = VPBB;
}
}
+
+void VPlanTransforms::introduceMasksAndLinearize(VPlan &Plan) {
+ // Nested loop regions (outer-loop vectorization) are not supported yet.
+ if (Plan.isOuterLoop())
+ return;
+ VPPredicator(Plan).run();
+}
More information about the llvm-commits
mailing list