1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

Make the range calculations for addrecs to be more conservative,

as they aren't currently prepared to handle complicated overflow
cases.

llvm-svn: 76524
This commit is contained in:
Dan Gohman 2009-07-21 00:42:47 +00:00
parent 4100aea6ad
commit 00fa00fec8

View File

@ -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;