[llvm] [VPlan] Use BlockFrequencyInfo in getPredBlockCostDivisor (PR #158690)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 17 23:07:41 PST 2025


================
@@ -2875,6 +2866,18 @@ bool LoopVectorizationCostModel::isPredicatedInst(Instruction *I) const {
   }
 }
 
+unsigned LoopVectorizationCostModel::getPredBlockCostDivisor(
+    TargetTransformInfo::TargetCostKind CostKind, const BasicBlock *BB) const {
+  if (CostKind == TTI::TCK_CodeSize)
----------------
lukel97 wrote:

Sorry for the late reply, this slipped through the cracks!

I think the intention is that BFI will now handle tail folded loops automatically, i.e. it will give us a probability of 1 for non predicated blocks in the loop. Since if a block isn't predicated, then it will execute the same number of times as the header, so HeaderFreq / BBFreq = 1. 

I gave this a quick check anyway just to confirm and adding back the `if (!Legal->blockNeedsPredication(BB)) return 1` doesn't change any of the tests.

https://github.com/llvm/llvm-project/pull/158690


More information about the llvm-commits mailing list