aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorJakub Staszak <jstaszak@apple.com>2011-07-31 04:47:20 +0000
committerJakub Staszak <jstaszak@apple.com>2011-07-31 04:47:20 +0000
commita385c20d427d8ec1a91ce8bf34612bf4c87cc34f (patch)
treefbfbbc545c33383fa4c09579850201542b4d71e8 /lib/Analysis
parent592ad6a82facd7d7ee58c599767a1b0c85eda0c5 (diff)
Do not handle case where LHS is equal to zero, because InstCombiner always moves
it to RHS anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136586 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/BranchProbabilityInfo.cpp32
1 files changed, 8 insertions, 24 deletions
diff --git a/lib/Analysis/BranchProbabilityInfo.cpp b/lib/Analysis/BranchProbabilityInfo.cpp
index 5a7d6bf59a..014cedc1d5 100644
--- a/lib/Analysis/BranchProbabilityInfo.cpp
+++ b/lib/Analysis/BranchProbabilityInfo.cpp
@@ -287,21 +287,9 @@ bool BranchProbabilityAnalysis::calcZeroHeuristics(BasicBlock *BB) {
if (!CI)
return false;
- Value *LHS = CI->getOperand(0);
Value *RHS = CI->getOperand(1);
-
- bool hasZero = false;
- bool lhsZero = false;
- if (ConstantInt *CI = dyn_cast<ConstantInt>(LHS)) {
- hasZero = CI->isZero();
- lhsZero = true;
- }
-
- if (!hasZero)
- if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
- hasZero = CI->isZero();
-
- if (!hasZero)
+ ConstantInt *CV = dyn_cast<ConstantInt>(RHS);
+ if (!CV || !CV->isZero())
return false;
bool isProb;
@@ -321,11 +309,9 @@ bool BranchProbabilityAnalysis::calcZeroHeuristics(BasicBlock *BB) {
case CmpInst::ICMP_SLT:
case CmpInst::ICMP_SLE:
// Less or equal to zero is not expected.
- // 0 < X -> isProb = true
- // 0 <= X -> isProb = true
- // X < 0 -> isProb = false
- // X <= 0 -> isProb = false
- isProb = lhsZero;
+ // X < 0 -> Unlikely
+ // X <= 0 -> Unlikely
+ isProb = false;
break;
case CmpInst::ICMP_UGT:
@@ -333,11 +319,9 @@ bool BranchProbabilityAnalysis::calcZeroHeuristics(BasicBlock *BB) {
case CmpInst::ICMP_SGT:
case CmpInst::ICMP_SGE:
// Greater or equal to zero is expected.
- // 0 > X -> isProb = false
- // 0 >= X -> isProb = false
- // X > 0 -> isProb = true
- // X >= 0 -> isProb = true
- isProb = !lhsZero;
+ // X > 0 -> Likely
+ // X >= 0 -> Likely
+ isProb = true;
break;
default: