[llvm-branch-commits] [llvm] Patch 5: [LV] create predicated(tail-folded) vplans. (PR #207815)
Sander de Smalen via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jul 17 02:23:33 PDT 2026
================
@@ -5911,33 +5937,32 @@ std::pair<VectorizationFactor, VPlan *> LoopVectorizationPlanner::computeBestVF(
continue;
}
- assert(P->isCompatibleWithTF(CM.foldTailByMasking()) &&
- "All vplans must be compatible with the CM");
- InstructionCost Cost =
- cost(*P, VF, ConsiderRegPressure ? &RUs[I] : nullptr, CM);
- VectorizationFactor CurrentFactor(VF, Cost, ScalarCost);
-
- if (isMoreProfitable(CurrentFactor, BestFactor, P->hasScalarTail())) {
- BestFactor = CurrentFactor;
- PlanForBestVF = P.get();
- }
+ if (P->isCompatibleWithTF(CM.foldTailByMasking())) {
+ InstructionCost Cost =
+ cost(*P, VF, ConsiderRegPressure ? &RUs[I] : nullptr, CM);
+ VectorizationFactor CurrentFactor(VF, Cost, ScalarCost);
- // If profitable add it to ProfitableVF list.
- if (isMoreProfitable(CurrentFactor, ScalarFactor, P->hasScalarTail()))
- ProfitableVFs.push_back(CurrentFactor);
+ if (isMoreProfitable(CurrentFactor, BestFactor, P->hasScalarTail())) {
+ BestFactor = CurrentFactor;
+ PlanForBestVF = P.get();
+ }
- if (EpilogueTailFoldingCM) {
- // Get the costs for the EpilogueTailFoldingCM:
+ // If profitable add it to ProfitableVF list.
+ if (isMoreProfitable(CurrentFactor, ScalarFactor, P->hasScalarTail()))
+ ProfitableVFs.push_back(CurrentFactor);
+ }
+ // Get the costs for the EpilogueTailFoldingCM:
+ if (EpilogueTailFoldingCM &&
+ P->isCompatibleWithTF(EpilogueTailFoldingCM->foldTailByMasking())) {
----------------
sdesmalen-arm wrote:
Actually, which cost-model is used shouldn't really matter anymore at this point. Because the plan has been constructed, it contains all the information about predication. There should be no information in the cost-model about predication, that isn't already represented in the plan itself. So instead of passing in the `EpilogueTailFoldingCM` I think it should just be a 'bool' to prefer selecting a tail-folded epilogue plan. It can just use the default CM.
https://github.com/llvm/llvm-project/pull/207815
More information about the llvm-branch-commits
mailing list