summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-09-05 23:25:16 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-09-05 23:25:16 +0000
commit77b7352db027cb486d25a92c2756c379a3073d7f (patch)
tree37abbda921f303171f556c95b34bb734a62fa18d /lib/Analysis
parent1fac6b50ea720d75fc2bf01a288e99f239869e90 (diff)
downloadllvm-77b7352db027cb486d25a92c2756c379a3073d7f.tar.gz
llvm-77b7352db027cb486d25a92c2756c379a3073d7f.tar.bz2
llvm-77b7352db027cb486d25a92c2756c379a3073d7f.tar.xz
Teach SCEV to report a max backedge count in one interesting case in
HowFarToZero; the case for a canonical loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139126 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/ScalarEvolution.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 8859c3b22f..a2cd38b4bf 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/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