Skip to content

Commit 6c6b40b

Browse files
author
Serguei Katkov
committedApr 28, 2018
[SCEV] Reduce the number of invocation to non trivial getExact function
The invocation of getExact in ScalarEvolution::getBackedgeTakenInfo is used only for getting statistic and for assert. Even if statistics is disabled, the code related to it will be eliminated the invocation to getExact itself will not be eliminated because it may have side-effects like creation of new SCEVs. So do invocation only when we collect statistics or executes asserts. Reviewers: mkazantsev, sanjoy, javed.absar Reviewed By: javed.absar Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46178 llvm-svn: 331099
1 parent e7e8772 commit 6c6b40b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed
 

‎llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6512,8 +6512,10 @@ ScalarEvolution::getBackedgeTakenInfo(const Loop *L) {
65126512
// must be cleared in this scope.
65136513
BackedgeTakenInfo Result = computeBackedgeTakenCount(L);
65146514

6515-
if (Result.getExact(L, this) != getCouldNotCompute()) {
6516-
assert(isLoopInvariant(Result.getExact(L, this), L) &&
6515+
#if LLVM_ENABLE_STATS || !defined(NDEBUG)
6516+
const SCEV *BEExact = Result.getExact(L, this);
6517+
if (BEExact != getCouldNotCompute()) {
6518+
assert(isLoopInvariant(BEExact, L) &&
65176519
isLoopInvariant(Result.getMax(this), L) &&
65186520
"Computed backedge-taken count isn't loop invariant for loop!");
65196521
++NumTripCountsComputed;
@@ -6523,6 +6525,7 @@ ScalarEvolution::getBackedgeTakenInfo(const Loop *L) {
65236525
// Only count loops that have phi nodes as not being computable.
65246526
++NumTripCountsNotComputed;
65256527
}
6528+
#endif // LLVM_ENABLE_STATS || !defined(NDEBUG)
65266529

65276530
// Now that we know more about the trip count for this loop, forget any
65286531
// existing SCEV values for PHI nodes in this loop since they are only

0 commit comments

Comments
 (0)
Please sign in to comment.