diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -13968,6 +13968,24 @@ }; VerifyBECountUsers(/* Predicated */ false); VerifyBECountUsers(/* Predicated */ true); + + // Verify intergity of loop disposition cache. + for (const auto &It : LoopDispositions) { + const SCEV *S = It.first; + auto &Values = It.second; + for (auto &V : Values) { + auto CachedDisposition = V.getInt(); + const auto *Loop = V.getPointer(); + const auto RecomputedDisposition = SE2.getLoopDisposition(S, Loop); + if (CachedDisposition != RecomputedDisposition) { + dbgs() << "Cached disposition of " << *S << " for loop " << *Loop + << " is incorrect: cached " + << loopDispositionToStr(CachedDisposition) << ", actual " + << loopDispositionToStr(RecomputedDisposition) << "\n"; + std::abort(); + } + } + } } bool ScalarEvolution::invalidate( diff --git a/llvm/test/Transforms/LoopFusion/double_loop_nest_inner_guard.ll b/llvm/test/Transforms/LoopFusion/double_loop_nest_inner_guard.ll --- a/llvm/test/Transforms/LoopFusion/double_loop_nest_inner_guard.ll +++ b/llvm/test/Transforms/LoopFusion/double_loop_nest_inner_guard.ll @@ -1,4 +1,7 @@ ; RUN: opt -S -loop-fusion < %s 2>&1 | FileCheck %s +; XFAIL: * +; REQUIRES: asserts +; Fails due to incorrect cached loop disposition. ; Verify that LoopFusion can fuse two double-loop nests with guarded inner ; loops. Loops are in canonical form. diff --git a/llvm/test/Transforms/LoopFusion/loop_nest.ll b/llvm/test/Transforms/LoopFusion/loop_nest.ll --- a/llvm/test/Transforms/LoopFusion/loop_nest.ll +++ b/llvm/test/Transforms/LoopFusion/loop_nest.ll @@ -1,4 +1,7 @@ ; RUN: opt -S -loop-fusion < %s | FileCheck %s +; XFAIL: * +; REQUIRES: asserts +; Fails due to incorrect cached loop disposition. ; ; int A[1024][1024]; ; int B[1024][1024]; diff --git a/llvm/test/Transforms/LoopFusion/triple_loop_nest_inner_guard.ll b/llvm/test/Transforms/LoopFusion/triple_loop_nest_inner_guard.ll --- a/llvm/test/Transforms/LoopFusion/triple_loop_nest_inner_guard.ll +++ b/llvm/test/Transforms/LoopFusion/triple_loop_nest_inner_guard.ll @@ -1,4 +1,7 @@ ; RUN: opt -S -loop-fusion < %s 2>&1 | FileCheck %s +; XFAIL: * +; REQUIRES: asserts +; Fails due to incorrect cached loop disposition. ; Verify that LoopFusion can fuse two triple-loop nests with guarded inner ; loops. Loops are in canonical form.