@@ -8647,8 +8647,28 @@ ScalarEvolution::BackedgeTakenInfo::getConstantMax(ScalarEvolution *SE) const {
8647
8647
const SCEV *
8648
8648
ScalarEvolution::BackedgeTakenInfo::getSymbolicMax(const Loop *L,
8649
8649
ScalarEvolution *SE) {
8650
- if (!SymbolicMax)
8651
- SymbolicMax = SE->computeSymbolicMaxBackedgeTakenCount(L);
8650
+ if (!SymbolicMax) {
8651
+ // Form an expression for the maximum exit count possible for this loop. We
8652
+ // merge the max and exact information to approximate a version of
8653
+ // getConstantMaxBackedgeTakenCount which isn't restricted to just
8654
+ // constants.
8655
+ SmallVector<const SCEV *, 4> ExitCounts;
8656
+
8657
+ for (const auto &ENT : ExitNotTaken) {
8658
+ const SCEV *ExitCount = ENT.SymbolicMaxNotTaken;
8659
+ if (!isa<SCEVCouldNotCompute>(ExitCount)) {
8660
+ assert(SE->DT.dominates(ENT.ExitingBlock, L->getLoopLatch()) &&
8661
+ "We should only have known counts for exiting blocks that "
8662
+ "dominate latch!");
8663
+ ExitCounts.push_back(ExitCount);
8664
+ }
8665
+ }
8666
+ if (ExitCounts.empty())
8667
+ SymbolicMax = SE->getCouldNotCompute();
8668
+ else
8669
+ SymbolicMax =
8670
+ SE->getUMinFromMismatchedTypes(ExitCounts, /*Sequential*/ true);
8671
+ }
8652
8672
return SymbolicMax;
8653
8673
}
8654
8674
@@ -14964,30 +14984,6 @@ bool ScalarEvolution::matchURem(const SCEV *Expr, const SCEV *&LHS,
14964
14984
return false;
14965
14985
}
14966
14986
14967
- const SCEV *
14968
- ScalarEvolution::computeSymbolicMaxBackedgeTakenCount(const Loop *L) {
14969
- SmallVector<BasicBlock*, 16> ExitingBlocks;
14970
- L->getExitingBlocks(ExitingBlocks);
14971
-
14972
- // Form an expression for the maximum exit count possible for this loop. We
14973
- // merge the max and exact information to approximate a version of
14974
- // getConstantMaxBackedgeTakenCount which isn't restricted to just constants.
14975
- SmallVector<const SCEV*, 4> ExitCounts;
14976
- for (BasicBlock *ExitingBB : ExitingBlocks) {
14977
- const SCEV *ExitCount =
14978
- getExitCount(L, ExitingBB, ScalarEvolution::SymbolicMaximum);
14979
- if (!isa<SCEVCouldNotCompute>(ExitCount)) {
14980
- assert(DT.dominates(ExitingBB, L->getLoopLatch()) &&
14981
- "We should only have known counts for exiting blocks that "
14982
- "dominate latch!");
14983
- ExitCounts.push_back(ExitCount);
14984
- }
14985
- }
14986
- if (ExitCounts.empty())
14987
- return getCouldNotCompute();
14988
- return getUMinFromMismatchedTypes(ExitCounts, /*Sequential*/ true);
14989
- }
14990
-
14991
14987
/// A rewriter to replace SCEV expressions in Map with the corresponding entry
14992
14988
/// in the map. It skips AddRecExpr because we cannot guarantee that the
14993
14989
/// replacement is loop invariant in the loop of the AddRec.
0 commit comments