From: Philip Reames Date: Fri, 19 Nov 2021 16:40:24 +0000 (-0800) Subject: [SCEV] Revert two speculative compile time optimizations which made no difference X-Git-Tag: upstream/15.0.7~25214 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=28000587e1a4133d00186825d3e346af27ed39ad;p=platform%2Fupstream%2Fllvm.git [SCEV] Revert two speculative compile time optimizations which made no difference Revert "[SCEV] Defer all work from ea12c2cb as late as possible" Revert "[SCEV] Defer loop property checks from ea12c2cb as late as possible" This reverts commit 734abbad79dbcbd0e880510fbab1ef0e701cfc7b and 1a5666acb281c7510504e726ba481d09ab5f5b95. Both of these changes were speculative attempts to address a compile time regression. Neither worked, and both complicated the code in undesirable ways. --- diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 40bd1b5..f7c22cf 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -8321,14 +8321,8 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L, // the same values on self-wrap of the IV, then we can infer that IV // doesn't self wrap because if it did, we'd have an infinite (undefined) // loop. - if (ControlsExit) { - auto deferredLoopProperties = [&]() { - // Conceptually, these two checks should be in the immediately guarding - // if clause, but we defer their actual execution to after the cheaper - // checks have all been done. - return isLoopInvariant(RHS, L) && loopHasNoAbnormalExits(L) && - loopIsFiniteByAssumption(L); - }; + if (ControlsExit && isLoopInvariant(RHS, L) && loopHasNoAbnormalExits(L) && + loopIsFiniteByAssumption(L)) { // TODO: We can peel off any functions which are invertible *in L*. Loop // invariant terms are effectively constants for our purposes here. @@ -8336,16 +8330,14 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L, if (auto *ZExt = dyn_cast(LHS)) InnerLHS = ZExt->getOperand(); if (const SCEVAddRecExpr *AR = dyn_cast(InnerLHS)) { - if (!AR->hasNoSelfWrap() && AR->getLoop() == L && AR->isAffine()) { - auto *StrideC = dyn_cast(AR->getStepRecurrence(*this)); - if (StrideC && StrideC->getAPInt().isPowerOf2() && - deferredLoopProperties()) { - auto Flags = AR->getNoWrapFlags(); - Flags = setFlags(Flags, SCEV::FlagNW); - SmallVector Operands{AR->operands()}; - Flags = StrengthenNoWrapFlags(this, scAddRecExpr, Operands, Flags); - setNoWrapFlags(const_cast(AR), Flags); - } + auto *StrideC = dyn_cast(AR->getStepRecurrence(*this)); + if (!AR->hasNoSelfWrap() && AR->getLoop() == L && AR->isAffine() && + StrideC && StrideC->getAPInt().isPowerOf2()) { + auto Flags = AR->getNoWrapFlags(); + Flags = setFlags(Flags, SCEV::FlagNW); + SmallVector Operands{AR->operands()}; + Flags = StrengthenNoWrapFlags(this, scAddRecExpr, Operands, Flags); + setNoWrapFlags(const_cast(AR), Flags); } } }