[llvm] [LV] Mark functions in legacy cost model const (NFC) (PR #216282)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 02:41:35 PDT 2026


================
@@ -2496,8 +2488,8 @@ uint64_t LoopVectorizationCostModel::getPredBlockCostDivisor(
     return 1;
 
   uint64_t HeaderFreq =
-      getBFI().getBlockFreq(TheLoop->getHeader()).getFrequency();
-  uint64_t BBFreq = getBFI().getBlockFreq(BB).getFrequency();
+      GetBFI().getBlockFreq(TheLoop->getHeader()).getFrequency();
----------------
lukel97 wrote:

The std::function can't be inlined here because it can't see the definition at the call site here. The instructions retired counter also won't surface the regression due to an indirect function call because it's the same number of instructions, but a branch prediction failure.

getPredBlockCostDivisor is a very hot method so it makes sense to optimise for compile time here.

The rest of this PR looks fine, maybe its worth carving out this change for a separate discussion?

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


More information about the llvm-commits mailing list