[llvm] [VPlan] Thread branch weights into VPlan and use them for cost (NFCI) (PR #209309)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 00:11:15 PDT 2026
================
@@ -2514,9 +2530,26 @@ uint64_t LoopVectorizationCostModel::getPredBlockCostDivisor(
uint64_t BBFreq = getBFI().getBlockFreq(BB).getFrequency();
assert(HeaderFreq >= BBFreq &&
"Header has smaller block freq than dominated BB?");
+ // Treat a zero frequency (e.g. a block BFI considers unreachable) as
+ // always-executed, avoiding a division by zero.
+ if (BBFreq == 0)
+ return 1;
----------------
lukel97 wrote:
Just to check, is this needed now because we eagerly compute block frequencies during construction, before unreachable blocks have been deleted?
https://github.com/llvm/llvm-project/pull/209309
More information about the llvm-commits
mailing list