STATISTIC(NumBruteForceTripCountsComputed,
"Number of loops with trip counts computed by force");
+// FIXME: Enable this with EXPENSIVE_CHECKS when the test suite is clean.
+bool llvm::VerifySCEV = false;
+
static cl::opt<unsigned>
MaxBruteForceIterations("scalar-evolution-max-iterations", cl::ReallyHidden,
cl::ZeroOrMore,
"derived loop"),
cl::init(100));
-// FIXME: Enable this with EXPENSIVE_CHECKS when the test suite is clean.
-static cl::opt<bool> VerifySCEV(
- "verify-scev", cl::Hidden,
+static cl::opt<bool, true> VerifySCEVOpt(
+ "verify-scev", cl::Hidden, cl::location(VerifySCEV),
cl::desc("Verify ScalarEvolution's backedge taken counts (slow)"));
static cl::opt<bool> VerifySCEVStrict(
"verify-scev-strict", cl::Hidden,
if (!ReachableBlocks.contains(L->getHeader()))
continue;
- auto *CurBECount = SCM.visit(
- const_cast<ScalarEvolution *>(this)->getBackedgeTakenCount(L));
+ // Only verify cached BECounts. Computing new BECounts may change the
+ // results of subsequent SCEV uses.
+ auto It = BackedgeTakenCounts.find(L);
+ if (It == BackedgeTakenCounts.end())
+ continue;
+
+ auto *CurBECount =
+ SCM.visit(It->second.getExact(L, const_cast<ScalarEvolution *>(this)));
auto *NewBECount = SE2.getBackedgeTakenCount(L);
if (CurBECount == SE2.getCouldNotCompute() ||
-; RUN: opt -indvars -stats -disable-output < %s 2>&1 | FileCheck %s --check-prefix=STATS
-; RUN: opt -indvars -S < %s | FileCheck %s --check-prefix=IR
-; REQUIRES: asserts
+; RUN: opt -indvars -S < %s | FileCheck %s
; Check that IndVarSimplify's result is not influenced by stray calls to
; ScalarEvolution in debug builds. However, -verify-indvars may still do
; such calls.
; llvm.org/PR44815
-; STATS: 1 scalar-evolution - Number of loops with trip counts computed by force
-; STATS: 2 scalar-evolution - Number of loops with predictable loop counts
-
; In this test, adding -verify-indvars causes %tmp13 to not be optimized away.
-; IR-LABEL: @foo
-; IR-NOT: phi i32
+; CHECK-LABEL: @foo
+; CHECK-NOT: phi i32
target triple = "x86_64-unknown-linux-gnu"
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -S -passes='loop(indvars),verify<scalar-evolution>' %s | FileCheck %s
+; RUN: opt -S -indvars -verify-scev %s | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
target triple = "x86_64-unknown-linux-gnu"