aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-21 00:42:47 +0000
committerDan Gohman <gohman@apple.com>2009-07-21 00:42:47 +0000
commita16b5764e3a39d37178864592d7bf7c483676079 (patch)
tree60b2194d1ded616a358b6c8ad9deed3790959f45 /lib/Analysis/ScalarEvolution.cpp
parentc2b015e4c0151ca7144438afd98e6f7091656e5d (diff)
Make the range calculations for addrecs to be more conservative,
as they aren't currently prepared to handle complicated overflow cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 13c734027c..20b2aa48c1 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -2619,10 +2619,15 @@ ScalarEvolution::getUnsignedRange(const SCEV *S) {
MaxBECount = getNoopOrZeroExtend(MaxBECount, Ty);
const SCEV *Start = AddRec->getStart();
+ const SCEV *Step = AddRec->getStepRecurrence(*this);
const SCEV *End = AddRec->evaluateAtIteration(MaxBECount, *this);
// Check for overflow.
- if (!isKnownPredicate(ICmpInst::ICMP_ULE, Start, End))
+ // TODO: This is very conservative.
+ if (!(Step->isOne() &&
+ isKnownPredicate(ICmpInst::ICMP_ULT, Start, End)) &&
+ !(Step->isAllOnesValue() &&
+ isKnownPredicate(ICmpInst::ICMP_UGT, Start, End)))
return FullSet;
ConstantRange StartRange = getUnsignedRange(Start);
@@ -2728,9 +2733,10 @@ ScalarEvolution::getSignedRange(const SCEV *S) {
const SCEV *End = AddRec->evaluateAtIteration(MaxBECount, *this);
// Check for overflow.
- if (!(isKnownPositive(Step) &&
+ // TODO: This is very conservative.
+ if (!(Step->isOne() &&
isKnownPredicate(ICmpInst::ICMP_SLT, Start, End)) &&
- !(isKnownNegative(Step) &&
+ !(Step->isAllOnesValue() &&
isKnownPredicate(ICmpInst::ICMP_SGT, Start, End)))
return FullSet;