aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-05-09 12:32:42 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-05-09 12:32:42 +0000
commit361e54d433e67db5d6b6455f7fd098de8c01f882 (patch)
tree9a651fda61ff46e13b4c756dc35b6c4bffd31bd6 /lib/Analysis/ScalarEvolution.cpp
parentcea03cdb6946841a951f6c622b117459ea5ca157 (diff)
Allow scalar evolution to compute iteration counts for loops with a
pointer-based condition. This fixes PR3171. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71354 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index e65cdd218a..107a7c4d81 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -2372,10 +2372,8 @@ ScalarEvolution::ComputeBackedgeTakenCount(const Loop *L) {
ICmpInst *ExitCond = dyn_cast<ICmpInst>(ExitBr->getCondition());
- // If it's not an integer comparison then compute it the hard way.
- // Note that ICmpInst deals with pointer comparisons too so we must check
- // the type of the operand.
- if (ExitCond == 0 || isa<PointerType>(ExitCond->getOperand(0)->getType()))
+ // If it's not an integer or pointer comparison then compute it the hard way.
+ if (ExitCond == 0)
return ComputeBackedgeTakenCountExhaustively(L, ExitBr->getCondition(),
ExitBr->getSuccessor(0) == ExitBlock);
@@ -2416,21 +2414,12 @@ ScalarEvolution::ComputeBackedgeTakenCount(const Loop *L) {
if (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS))
if (const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(LHS))
if (AddRec->getLoop() == L) {
- // Form the comparison range using the constant of the correct type so
- // that the ConstantRange class knows to do a signed or unsigned
- // comparison.
- ConstantInt *CompVal = RHSC->getValue();
- const Type *RealTy = ExitCond->getOperand(0)->getType();
- CompVal = dyn_cast<ConstantInt>(
- ConstantExpr::getBitCast(CompVal, RealTy));
- if (CompVal) {
- // Form the constant range.
- ConstantRange CompRange(
- ICmpInst::makeConstantRange(Cond, CompVal->getValue()));
-
- SCEVHandle Ret = AddRec->getNumIterationsInRange(CompRange, *this);
- if (!isa<SCEVCouldNotCompute>(Ret)) return Ret;
- }
+ // Form the constant range.
+ ConstantRange CompRange(
+ ICmpInst::makeConstantRange(Cond, RHSC->getValue()->getValue()));
+
+ SCEVHandle Ret = AddRec->getNumIterationsInRange(CompRange, *this);
+ if (!isa<SCEVCouldNotCompute>(Ret)) return Ret;
}
switch (Cond) {