[llvm] bb68b24 - [SCEV] Verify contents of loop disposition cache
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 19 03:49:58 PDT 2022
Author: Max Kazantsev
Date: 2022-09-19T17:43:00+07:00
New Revision: bb68b2402daa980ff41406a7ecf5e9f4e131b420
URL: https://github.com/llvm/llvm-project/commit/bb68b2402daa980ff41406a7ecf5e9f4e131b420
DIFF: https://github.com/llvm/llvm-project/commit/bb68b2402daa980ff41406a7ecf5e9f4e131b420.diff
LOG: [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
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Transforms/LoopFusion/double_loop_nest_inner_guard.ll
llvm/test/Transforms/LoopFusion/loop_nest.ll
llvm/test/Transforms/LoopFusion/triple_loop_nest_inner_guard.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 4bf975ff9e284..31204a41df5ca 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -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(
diff --git a/llvm/test/Transforms/LoopFusion/double_loop_nest_inner_guard.ll b/llvm/test/Transforms/LoopFusion/double_loop_nest_inner_guard.ll
index d94c2229a0fc8..caa122071b6c3 100644
--- 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
index 44a0ac8093da9..b9591728dd3dc 100644
--- 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
index 065b250c0c14c..b72b1995f1aa8 100644
--- 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.
More information about the llvm-commits
mailing list