[llvm] [LV] Remove selectUserVF, remove use of legacy expectedCost (NFCI) (PR #191216)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 17 01:29:50 PDT 2026
================
@@ -6653,20 +6617,26 @@ void LoopVectorizationPlanner::plan(ElementCount UserVF, unsigned UserIC) {
// Collect the instructions (and their associated costs) that will be more
// profitable to scalarize.
CM.collectInLoopReductions();
- if (CM.selectUserVectorizationFactor(UserVF)) {
- LLVM_DEBUG(dbgs() << "LV: Using user VF " << UserVF << ".\n");
- ElementCount EpilogueUserVF =
- ElementCount::getFixed(EpilogueVectorizationForceVF);
- if (EpilogueUserVF.isVector() &&
- ElementCount::isKnownLT(EpilogueUserVF, UserVF) &&
- CM.selectUserVectorizationFactor(EpilogueUserVF)) {
- // Build a separate plan for the forced epilogue VF.
- buildVPlansWithVPRecipes(EpilogueUserVF, EpilogueUserVF);
+ CM.collectNonVectorizedAndSetWideningDecisions(UserVF);
+ ElementCount EpilogueUserVF =
+ ElementCount::getFixed(EpilogueVectorizationForceVF);
+ if (EpilogueUserVF.isVector() &&
+ ElementCount::isKnownLT(EpilogueUserVF, UserVF)) {
+ CM.collectNonVectorizedAndSetWideningDecisions(EpilogueUserVF);
+ buildVPlansWithVPRecipes(EpilogueUserVF, EpilogueUserVF);
+ }
+ buildVPlansWithVPRecipes(UserVF, UserVF);
+ if (!VPlans.empty()) {
+ // For scalar VF, skip VPlan cost check as VPlan cost is designed for
+ // vector VFs only.
+ if (UserVF.isScalar() ||
+ cost(*VPlans.back(), UserVF, /*RU=*/nullptr).isValid()) {
----------------
david-arm wrote:
I still think there is a potential problem here. We're assuming that `!VPlans.empty()` means the back plan is for the `UserVF`, which may not be true if the VPlan wasn't added. There is no guarantee that `buildVPlansWithVPRecipes` will actually add a plan.
https://github.com/llvm/llvm-project/pull/191216
More information about the llvm-commits
mailing list