[PATCH] D159336: Statically analyze likely and unlikely blocks based on metadata

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 15:49:45 PDT 2023

hiraditya added inline comments.

Comment at: llvm/lib/Transforms/IPO/HotColdSplitting.cpp:128
+  // [[unlikely]] and builtin_expect assigns 1/2000 as cold branch probability.
+  auto ColdProb = BranchProbability(1, std::min(2000, ColdBranchProbDenom.getValue()));
hiraditya wrote:
> tejohnson wrote:
> > Is there an internal option that determines the value used there that can be used in the code here? Looks like it is controlled by LikelyBranchWeight - can that be made a global option and referenced here so that they don't get out of sync?
> found one. it has a higher probability but that is what other parts of llvm is using so i'll use the same here.
TTI.getPredictableBranchThreshold is what i used. it seems this is the recommended API to use for branch threshold (https://llvm.org/doxygen/LowerExpectIntrinsic_8cpp_source.html)



More information about the llvm-commits mailing list