[llvm-commits] [llvm] r136586 - /llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
Jakub Staszak
jstaszak at apple.com
Sat Jul 30 21:47:20 PDT 2011
Author: kuba
Date: Sat Jul 30 23:47:20 2011
New Revision: 136586
URL: http://llvm.org/viewvc/llvm-project?rev=136586&view=rev
Log:
Do not handle case where LHS is equal to zero, because InstCombiner always moves
it to RHS anyway.
Modified:
llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
Modified: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp?rev=136586&r1=136585&r2=136586&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Sat Jul 30 23:47:20 2011
@@ -287,21 +287,9 @@
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 @@
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 @@
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:
More information about the llvm-commits
mailing list