[PATCH] D28393: [SCEV] Make howFarToZero produce a smaller max backedge-taken count
Sanjoy Das via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 10 14:42:18 PST 2017
sanjoy accepted this revision.
sanjoy added a comment.
This revision is now accepted and ready to land.
lgtm
================
Comment at: lib/Analysis/ScalarEvolution.cpp:7209
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);
----------------
I'd add a one-liner here:
```
// Solve {Distance,+,-1} == 0.
```
Repository:
rL LLVM
https://reviews.llvm.org/D28393
More information about the llvm-commits
mailing list