diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2017-01-11 20:55:48 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2017-01-11 20:55:48 +0000 |
commit | 83962656557bdea5499ec022094fd6c60c1db389 (patch) | |
tree | ffdf549ae4e30d4541050f3f9b323519fd019bbd /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | df60aa83a32a6f837a19fa8283435f328bbaf171 (diff) | |
download | bcm5719-llvm-83962656557bdea5499ec022094fd6c60c1db389.tar.gz bcm5719-llvm-83962656557bdea5499ec022094fd6c60c1db389.zip |
[SCEV] Make howFarToZero use a simpler formula for max backedge-taken count.
This is both easier to understand, and produces a tighter bound in certain
cases.
Differential Revision: https://reviews.llvm.org/D28393
llvm-svn: 291701
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 44f1a6dde0d..bd7e0e832f6 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -7206,17 +7206,8 @@ ScalarEvolution::howFarToZero(const SCEV *V, const Loop *L, bool ControlsExit, // 1*N = -Start; -1*N = Start (mod 2^BW), so: // N = Distance (as unsigned) if (StepC->getValue()->equalsInt(1) || StepC->getValue()->isAllOnesValue()) { - ConstantRange CR = getUnsignedRange(Start); - const SCEV *MaxBECount; - if (!CountDown && CR.getUnsignedMin().isMinValue()) - // When counting up, the worst starting value is 1, not 0. - MaxBECount = CR.getUnsignedMax().isMinValue() - ? getConstant(APInt::getMinValue(CR.getBitWidth())) - : getConstant(APInt::getMaxValue(CR.getBitWidth())); - else - MaxBECount = getConstant(CountDown ? CR.getUnsignedMax() - : -CR.getUnsignedMin()); - return ExitLimit(Distance, MaxBECount, false, Predicates); + APInt MaxBECount = getUnsignedRange(Distance).getUnsignedMax(); + return ExitLimit(Distance, getConstant(MaxBECount), false, Predicates); } // As a special case, handle the instance where Step is a positive power of |