Index: lib/Analysis/ScalarEvolution.cpp =================================================================== --- lib/Analysis/ScalarEvolution.cpp +++ lib/Analysis/ScalarEvolution.cpp @@ -6502,8 +6502,10 @@ // 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 + auto *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; @@ -6513,6 +6515,7 @@ // Only count loops that have phi nodes as not being computable. ++NumTripCountsNotComputed; } +#endif // 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