[llvm] r331099 - [SCEV] Reduce the number of invocation to non trivial getExact function
Serguei Katkov via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 27 20:53:37 PDT 2018
Author: skatkov
Date: Fri Apr 27 20:53:36 2018
New Revision: 331099
URL: http://llvm.org/viewvc/llvm-project?rev=331099&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=331099&r1=331098&r2=331099&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Apr 27 20:53:36 2018
@@ -6512,8 +6512,10 @@ ScalarEvolution::getBackedgeTakenInfo(co
// must be cleared in this scope.
BackedgeTakenInfo Result = computeBackedgeTakenCount(L);
- if (Result.getExact(L, this) != getCouldNotCompute()) {
- assert(isLoopInvariant(Result.getExact(L, this), L) &&
+#if LLVM_ENABLE_STATS || !defined(NDEBUG)
+ const SCEV *BEExact = Result.getExact(L, this);
+ if (BEExact != getCouldNotCompute()) {
+ assert(isLoopInvariant(BEExact, L) &&
isLoopInvariant(Result.getMax(this), L) &&
"Computed backedge-taken count isn't loop invariant for loop!");
++NumTripCountsComputed;
@@ -6523,6 +6525,7 @@ ScalarEvolution::getBackedgeTakenInfo(co
// Only count loops that have phi nodes as not being computable.
++NumTripCountsNotComputed;
}
+#endif // LLVM_ENABLE_STATS || !defined(NDEBUG)
// Now that we know more about the trip count for this loop, forget any
// existing SCEV values for PHI nodes in this loop since they are only
More information about the llvm-commits
mailing list