diff options
author | Max Kazantsev <max.kazantsev@azul.com> | 2017-10-25 11:07:43 +0000 |
---|---|---|
committer | Max Kazantsev <max.kazantsev@azul.com> | 2017-10-25 11:07:43 +0000 |
commit | b6d40067af8ef18117d94c889e01824376a441c3 (patch) | |
tree | f45124b4df384bb869847e0abf551f2b1f572601 /llvm/lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | 0c7cd071f7916a4f9a0bdc70a58b8477c3700e38 (diff) | |
download | bcm5719-llvm-b6d40067af8ef18117d94c889e01824376a441c3.tar.gz bcm5719-llvm-b6d40067af8ef18117d94c889e01824376a441c3.zip |
[SCEV] Enhance SCEVFindUnsafe for division
This patch allows SCEVFindUnsafe algorithm to tread division by any non-positive
value as safe. Previously, it could only recognize non-zero constants.
Differential Revision: https://reviews.llvm.org/D39228
llvm-svn: 316568
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index 47bdac00ae1..964a79803fa 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -2250,10 +2250,6 @@ namespace { // only needed when the expression includes some subexpression that is not IV // derived. // -// Currently, we only allow division by a nonzero constant here. If this is -// inadequate, we could easily allow division by SCEVUnknown by using -// ValueTracking to check isKnownNonZero(). -// // We cannot generally expand recurrences unless the step dominates the loop // header. The expander handles the special case of affine recurrences by // scaling the recurrence outside the loop, but this technique isn't generally @@ -2268,13 +2264,11 @@ struct SCEVFindUnsafe { bool follow(const SCEV *S) { if (const SCEVUDivExpr *D = dyn_cast<SCEVUDivExpr>(S)) { - const SCEVConstant *SC = dyn_cast<SCEVConstant>(D->getRHS()); - if (!SC || SC->getValue()->isZero()) { + if (!SE.isKnownNonZero(D->getRHS())) { IsUnsafe = true; return false; } - } - if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S)) { + } else if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(S)) { const SCEV *Step = AR->getStepRecurrence(SE); if (!AR->isAffine() && !SE.dominates(Step, AR->getLoop()->getHeader())) { IsUnsafe = true; |