[llvm-commits] [llvm] r76524 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Dan Gohman
gohman at apple.com
Mon Jul 20 17:42:51 PDT 2009
Author: djg
Date: Mon Jul 20 19:42:47 2009
New Revision: 76524
URL: http://llvm.org/viewvc/llvm-project?rev=76524&view=rev
Log:
Make the range calculations for addrecs to be more conservative,
as they aren't currently prepared to handle complicated overflow
cases.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=76524&r1=76523&r2=76524&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jul 20 19:42:47 2009
@@ -2619,10 +2619,15 @@
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 @@
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;
More information about the llvm-commits
mailing list