From 11fa8e39fd25153c7d6420948f4b7562bf4e8240 Mon Sep 17 00:00:00 2001 From: Max Kazantsev Date: Fri, 27 Oct 2017 04:17:44 +0000 Subject: Revert rL316568 because of sudden performance drop on ARM git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316739 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ScalarEvolutionExpander.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp') diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 964a79803fa..47bdac00ae1 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -2250,6 +2250,10 @@ 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 @@ -2264,11 +2268,13 @@ struct SCEVFindUnsafe { bool follow(const SCEV *S) { if (const SCEVUDivExpr *D = dyn_cast(S)) { - if (!SE.isKnownNonZero(D->getRHS())) { + const SCEVConstant *SC = dyn_cast(D->getRHS()); + if (!SC || SC->getValue()->isZero()) { IsUnsafe = true; return false; } - } else if (const SCEVAddRecExpr *AR = dyn_cast(S)) { + } + if (const SCEVAddRecExpr *AR = dyn_cast(S)) { const SCEV *Step = AR->getStepRecurrence(SE); if (!AR->isAffine() && !SE.dominates(Step, AR->getLoop()->getHeader())) { IsUnsafe = true; -- cgit v1.2.3