[llvm] 2800058 - [SCEV] Revert two speculative compile time optimizations which made no difference
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 19 08:46:15 PST 2021
Author: Philip Reames
Date: 2021-11-19T08:45:56-08:00
New Revision: 28000587e1a4133d00186825d3e346af27ed39ad
URL: https://github.com/llvm/llvm-project/commit/28000587e1a4133d00186825d3e346af27ed39ad
DIFF: https://github.com/llvm/llvm-project/commit/28000587e1a4133d00186825d3e346af27ed39ad.diff
LOG: [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.
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 40bd1b593560e..f7c22cfb03100 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<SCEVZeroExtendExpr>(LHS))
InnerLHS = ZExt->getOperand();
if (const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(InnerLHS)) {
- if (!AR->hasNoSelfWrap() && AR->getLoop() == L && AR->isAffine()) {
- auto *StrideC = dyn_cast<SCEVConstant>(AR->getStepRecurrence(*this));
- if (StrideC && StrideC->getAPInt().isPowerOf2() &&
- deferredLoopProperties()) {
- auto Flags = AR->getNoWrapFlags();
- Flags = setFlags(Flags, SCEV::FlagNW);
- SmallVector<const SCEV*> Operands{AR->operands()};
- Flags = StrengthenNoWrapFlags(this, scAddRecExpr, Operands, Flags);
- setNoWrapFlags(const_cast<SCEVAddRecExpr *>(AR), Flags);
- }
+ auto *StrideC = dyn_cast<SCEVConstant>(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<const SCEV*> Operands{AR->operands()};
+ Flags = StrengthenNoWrapFlags(this, scAddRecExpr, Operands, Flags);
+ setNoWrapFlags(const_cast<SCEVAddRecExpr *>(AR), Flags);
}
}
}
More information about the llvm-commits
mailing list