diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp --- a/llvm/lib/Analysis/TargetTransformInfo.cpp +++ b/llvm/lib/Analysis/TargetTransformInfo.cpp @@ -37,6 +37,11 @@ cl::desc("Use this to override the target cache line size when " "specified by the user.")); +static cl::opt PredictableBranchThreshold( + "predictable-branch-threshold", cl::init(99), cl::Hidden, + cl::desc( + "Use this to override the target's predictable branch threshold (%).")); + namespace { /// No-op implementation of the TTI interface using the utility base /// classes. @@ -232,7 +237,9 @@ } BranchProbability TargetTransformInfo::getPredictableBranchThreshold() const { - return TTIImpl->getPredictableBranchThreshold(); + return PredictableBranchThreshold.getNumOccurrences() > 0 + ? BranchProbability(PredictableBranchThreshold, 100) + : TTIImpl->getPredictableBranchThreshold(); } bool TargetTransformInfo::hasBranchDivergence() const {