[llvm] [LV] Add VPlan planning context and result (PR #226415)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 02:48:27 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h llvm/lib/Transforms/Vectorize/LoopVectorize.cpp llvm/lib/Transforms/Vectorize/VPlan.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
index 199096bff..507f2af79 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
@@ -993,9 +993,10 @@ public:
/// Returns nullptr if epilogue vectorization is not supported or not
/// profitable for the loop. \p ScalarEpilogueAllowed indicates whether the
/// epilogue lowering policy permits creating a scalar epilogue at all.
- std::unique_ptr<VPlan> selectBestEpiloguePlan(
- const VPlanPlanningResult &EpilogueCandidates, VPlan &MainPlan,
- ElementCount MainLoopVF, unsigned IC, bool ScalarEpilogueAllowed);
+ std::unique_ptr<VPlan>
+ selectBestEpiloguePlan(const VPlanPlanningResult &EpilogueCandidates,
+ VPlan &MainPlan, ElementCount MainLoopVF, unsigned IC,
+ bool ScalarEpilogueAllowed);
/// Emit remarks for recipes with invalid costs in the available VPlans.
void emitInvalidCostRemarks(VPlanPlanningContext &Ctx,
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f4a659c16..9abe702f7 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -3718,10 +3718,8 @@ std::unique_ptr<VPlan> LoopVectorizationPlanner::selectBestEpiloguePlan(
return Clone;
}
-unsigned
-LoopVectorizationPlanner::selectInterleaveCount(VPlanPlanningContext &Ctx,
- ElementCount VF,
- InstructionCost LoopCost) {
+unsigned LoopVectorizationPlanner::selectInterleaveCount(
+ VPlanPlanningContext &Ctx, ElementCount VF, InstructionCost LoopCost) {
LoopVectorizationCostModel &CM = Ctx.getCostModel();
VPlan &Plan = Ctx.Result.getPlanFor(VF);
// -- The interleave heuristics --
@@ -5447,8 +5445,7 @@ void LoopVectorizationPlanner::plan(VPlanPlanningContext &Ctx,
if (!VPlans.empty() && VPlans.front()->getSingleVF() == UserVF) {
// For scalar VF, skip VPlan cost check as VPlan cost is designed for
// vector VFs only.
- if (UserVF.isScalar() ||
- cost(Ctx, UserVF, /*RU=*/nullptr).isValid()) {
+ if (UserVF.isScalar() || cost(Ctx, UserVF, /*RU=*/nullptr).isValid()) {
LLVM_DEBUG(dbgs() << "LV: Using user VF " << UserVF << ".\n");
LLVM_DEBUG(printPlans(Ctx, dbgs()));
return;
@@ -5677,8 +5674,7 @@ LoopVectorizationPlanner::computeBestVF(VPlanPlanningContext &Ctx) {
if (VPlans.size() == 1) {
// For outer loops, the plan has a single vector VF determined by the
// heuristic.
- assert((FirstPlan.hasScalarVFOnly() ||
- Ctx.Result.hasPlanWithVF(UserVF) ||
+ assert((FirstPlan.hasScalarVFOnly() || Ctx.Result.hasPlanWithVF(UserVF) ||
FirstPlan.isOuterLoop()) &&
"must have a single scalar VF, UserVF or an outer loop");
return {VectorizationFactor(FirstPlan.getSingleVF(), 0, 0), &FirstPlan};
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 9192d53fc..5028e52cb 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -1693,8 +1693,7 @@ VPlan &VPlanPlanningResult::getPlanFor(ElementCount VF) const {
}
bool VPlanPlanningResult::hasPlanWithVF(ElementCount VF) const {
- return any_of(VPlans,
- [VF](const VPlanPtr &Plan) { return Plan->hasVF(VF); });
+ return any_of(VPlans, [VF](const VPlanPtr &Plan) { return Plan->hasVF(VF); });
}
static void addRuntimeUnrollDisableMetaData(Loop *L) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/226415
More information about the llvm-commits
mailing list