[SCEV] Verify contents of loop disposition cache

It seems that it is sometimes broken. Initial motivation for this was
investigation of https://github.com/llvm/llvm-project/issues/56260, but
it also seems that we have found an unrelated bug in LoopFusion that leaves
broken caches.

Differential Revision: https://reviews.llvm.org/D134158
Reviewed By: nikic
This commit is contained in:
Max Kazantsev 2022-09-19 17:37:17 +07:00
parent 908b3b6ccb
commit bb68b2402d
4 changed files with 27 additions and 0 deletions

View File

@ -13968,6 +13968,24 @@ void ScalarEvolution::verify() const {
};
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(

View File

@ -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.

View File

@ -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];

View File

@ -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.