[llvm] [VPlan] Record estimated branch probabilities on VPlan0 for cost modeling (PR #216172)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 07:48:40 PDT 2026
================
@@ -5347,8 +5348,19 @@ void VPCostContext::invalidateWideningDecision(Instruction *I,
LoopVectorizationCostModel::CM_InvalidatedDecision, 0);
}
-uint64_t VPCostContext::getPredBlockCostDivisor(BasicBlock *BB) const {
- return CM.getPredBlockCostDivisor(CostKind, BB);
+uint64_t
+VPCostContext::getPredBlockCostDivisor(const VPRegionBlock *Region) const {
+ if (CostKind == TTI::TCK_CodeSize)
+ return 1;
+ std::optional<VPExecutionFrequency> Freq =
+ Region->getEntryBranchOnMask()->getExecutionFrequency();
+ if (!Freq)
+ return 1;
+ // A recorded frequency is neither zero nor always-executing, so the
+ // probability is non-zero and the division below is safe.
+ return divideNearest(
+ BranchProbability::getDenominator(),
+ vputils::getExecutionProbability(Freq->Freq).getNumerator());
----------------
lukel97 wrote:
IIUC BlockFrequencyInfo is now only used for the legacy cost model + widening decisions? Given that we now have our own VPlan BFI (computeExecutionFrequencies) I presume we'll want to eventually drop the dependency on BFI.
https://github.com/llvm/llvm-project/pull/216172
More information about the llvm-commits
mailing list