diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-09-05 23:25:16 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-09-05 23:25:16 +0000 |
commit | c4c43fbb07a14bdce98cf345c2b1a811c4b43d81 (patch) | |
tree | b15fbe3abb52333e55818333bb6edc3a0d062e92 /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | 73df7e383033a767ded013c2e013df18e6010aa0 (diff) | |
download | bcm5719-llvm-c4c43fbb07a14bdce98cf345c2b1a811c4b43d81.tar.gz bcm5719-llvm-c4c43fbb07a14bdce98cf345c2b1a811c4b43d81.zip |
Teach SCEV to report a max backedge count in one interesting case in
HowFarToZero; the case for a canonical loop.
llvm-svn: 139126
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 8859c3b22fb..a2cd38b4bf5 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -5184,8 +5184,12 @@ ScalarEvolution::HowFarToZero(const SCEV *V, const Loop *L) { // Handle unitary steps, which cannot wraparound. // 1*N = -Start; -1*N = Start (mod 2^BW), so: // N = Distance (as unsigned) - if (StepC->getValue()->equalsInt(1) || StepC->getValue()->isAllOnesValue()) - return Distance; + if (StepC->getValue()->equalsInt(1) || StepC->getValue()->isAllOnesValue()) { + ConstantRange CR = getUnsignedRange(Start); + const SCEV *MaxBECount = getConstant(CountDown ? CR.getUnsignedMax() + : ~CR.getUnsignedMin()); + return ExitLimit(Distance, MaxBECount); + } // If the recurrence is known not to wraparound, unsigned divide computes the // back edge count. We know that the value will either become zero (and thus |