diff options
author | Daniel Jasper <djasper@google.com> | 2015-04-14 15:20:37 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-04-14 15:20:37 +0000 |
commit | 8229ebb9263fb1a773ea48c632bc1e04ce6e1299 (patch) | |
tree | c71d7be567534f99f2eba546ebabc18ed2522b18 /llvm/lib/Analysis/BranchProbabilityInfo.cpp | |
parent | 2f16bc10957acf1e29306bc764cb4886d38024a9 (diff) | |
download | bcm5719-llvm-8229ebb9263fb1a773ea48c632bc1e04ce6e1299.tar.gz bcm5719-llvm-8229ebb9263fb1a773ea48c632bc1e04ce6e1299.zip |
The code that originally made me discover this is:
if ((a & 0x1) == 0x1) {
..
}
In this case we don't actually have any branch probability information and
should not assume to have any. LLVM transforms this into:
%and = and i32 %a, 1
%tobool = icmp eq i32 %and, 0
So, in this case, the result of a bitwise and is compared against 0,
but nevertheless, we should not assume to have probability
information.
llvm-svn: 234898
Diffstat (limited to 'llvm/lib/Analysis/BranchProbabilityInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/BranchProbabilityInfo.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/BranchProbabilityInfo.cpp b/llvm/lib/Analysis/BranchProbabilityInfo.cpp index 14800f4a28b..d7cee3afaf5 100644 --- a/llvm/lib/Analysis/BranchProbabilityInfo.cpp +++ b/llvm/lib/Analysis/BranchProbabilityInfo.cpp @@ -379,6 +379,14 @@ bool BranchProbabilityInfo::calcZeroHeuristics(BasicBlock *BB) { if (!CV) return false; + // If the LHS is the result of AND'ing a value with a single bit bitmask, + // we don't have information about probabilities. + if (Instruction *LHS = dyn_cast<Instruction>(CI->getOperand(0))) + if (LHS->getOpcode() == Instruction::And) + if (ConstantInt *AndRHS = dyn_cast<ConstantInt>(LHS->getOperand(1))) + if (AndRHS->getUniqueInteger().isPowerOf2()) + return false; + bool isProb; if (CV->isZero()) { switch (CI->getPredicate()) { |