[PATCH] D79830: Add support of __builtin_expect_with_probability
David Li via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 9 09:52:34 PDT 2020
davidxl added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp:58
+std::pair<uint32_t, uint32_t> setBranchWeight(Intrinsic::ID IntrinsicID,
+ CallInst *CI, int BranchCount) {
----------------
nit: change name to getBranchWeight or computeBranchWeight
================
Comment at: llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp:69
+ double TrueProb = Confidence->getValueAPF().convertToDouble();
+ double FalseProb = (1.0 - TrueProb) / (BranchCount - 1);
+ uint32_t LikelyBW = ceil((TrueProb * (double)(INT32_MAX - 1)) + 1.0);
----------------
assert TrueProb is in [0,1]
================
Comment at: llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp:96
+ uint32_t LikelyBranchWeightVal = WeightNums.first;
+ uint32_t UnlikelyBranchWeightVal = WeightNums.second;
+
----------------
simpler to use tuple and tie here.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79830/new/
https://reviews.llvm.org/D79830
More information about the cfe-commits
mailing list