[llvm] [LoopCacheAnalysis] Generate tests by update_analyze_test_checks.py (PR #204807)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 20 09:17:26 PDT 2026
https://github.com/kasuga-fj updated https://github.com/llvm/llvm-project/pull/204807
>From 9f78516192caad51d3c937129b3c489bb8ae4e3a Mon Sep 17 00:00:00 2001
From: Ryotaro Kasuga <kasuga.ryotaro at fujitsu.com>
Date: Fri, 19 Jun 2026 21:00:09 +0900
Subject: [PATCH] [LoopCacheAnalysis] Generate tests by
update_analyze_test_checks.py
---
.../include/llvm/Analysis/LoopCacheAnalysis.h | 4 +-
llvm/lib/Analysis/LoopCacheAnalysis.cpp | 37 ++++++++----
llvm/lib/Passes/PassRegistry.def | 2 +-
.../PowerPC/LoopnestFixedSize.ll | 29 +++++-----
.../PowerPC/compute-cost-m32.ll | 6 +-
.../LoopCacheAnalysis/PowerPC/compute-cost.ll | 32 +++++++----
.../LoopCacheAnalysis/PowerPC/loads-store.ll | 10 ++--
.../LoopCacheAnalysis/PowerPC/matmul.ll | 16 +++---
.../LoopCacheAnalysis/PowerPC/matvecmul.ll | 18 +++---
.../LoopCacheAnalysis/PowerPC/multi-store.ll | 16 +++---
.../LoopCacheAnalysis/PowerPC/single-store.ll | 19 ++++---
.../LoopCacheAnalysis/PowerPC/stencil.ll | 10 ++--
.../LoopCacheAnalysis/compute-cost.ll | 57 +++++++++++++------
.../interchange-cost-beneficial.ll | 15 ++---
.../interchange-refcost-overflow.ll | 12 ++--
.../partially-perfect-nest.ll | 25 ++++----
llvm/utils/UpdateTestChecks/common.py | 1 +
17 files changed, 190 insertions(+), 119 deletions(-)
diff --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
index c49215ee9b315..00ca85e97a636 100644
--- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h
@@ -288,9 +288,7 @@ class LoopCachePrinterPass
public:
explicit LoopCachePrinterPass(raw_ostream &OS) : OS(OS) {}
- LLVM_ABI PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR,
- LPMUpdater &U);
+ LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
};
} // namespace llvm
diff --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
index 91ef020eefbaf..caf1b1a655632 100644
--- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
@@ -560,9 +560,10 @@ CacheCost::CacheCost(const LoopVectorTy &Loops, const LoopInfo &LI,
calculateCacheFootprint();
}
-std::unique_ptr<CacheCost>
-CacheCost::getCacheCost(Loop &Root, LoopStandardAnalysisResults &AR,
- DependenceInfo &DI, std::optional<unsigned> TRT) {
+static std::unique_ptr<CacheCost>
+getCacheCostImpl(Loop &Root, LoopInfo &LI, ScalarEvolution &SE,
+ TargetTransformInfo &TTI, AAResults &AA, DependenceInfo &DI,
+ std::optional<unsigned> TRT) {
if (!Root.isOutermost()) {
LLVM_DEBUG(dbgs() << "Expecting the outermost loop in a loop nest\n");
return nullptr;
@@ -577,7 +578,13 @@ CacheCost::getCacheCost(Loop &Root, LoopStandardAnalysisResults &AR,
return nullptr;
}
- return std::make_unique<CacheCost>(Loops, AR.LI, AR.SE, AR.TTI, AR.AA, DI, TRT);
+ return std::make_unique<CacheCost>(Loops, LI, SE, TTI, AA, DI, TRT);
+}
+
+std::unique_ptr<CacheCost>
+CacheCost::getCacheCost(Loop &Root, LoopStandardAnalysisResults &AR,
+ DependenceInfo &DI, std::optional<unsigned> TRT) {
+ return getCacheCostImpl(Root, AR.LI, AR.SE, AR.TTI, AR.AA, DI, TRT);
}
void CacheCost::calculateCacheFootprint() {
@@ -713,14 +720,20 @@ CacheCostTy CacheCost::computeRefGroupCacheCost(const ReferenceGroupTy &RG,
//===----------------------------------------------------------------------===//
// LoopCachePrinterPass implementation
//
-PreservedAnalyses LoopCachePrinterPass::run(Loop &L, LoopAnalysisManager &AM,
- LoopStandardAnalysisResults &AR,
- LPMUpdater &U) {
- Function *F = L.getHeader()->getParent();
- DependenceInfo DI(F, &AR.AA, &AR.SE, &AR.LI);
-
- if (auto CC = CacheCost::getCacheCost(L, AR, DI))
- OS << *CC;
+PreservedAnalyses LoopCachePrinterPass::run(Function &F,
+ FunctionAnalysisManager &FAM) {
+ OS << "Printing analysis 'Loop Cache Analysis' for function '" << F.getName()
+ << "':\n";
+
+ auto &LI = FAM.getResult<LoopAnalysis>(F);
+ auto &SE = FAM.getResult<ScalarEvolutionAnalysis>(F);
+ auto &TTI = FAM.getResult<TargetIRAnalysis>(F);
+ auto &AA = FAM.getResult<AAManager>(F);
+ auto &DI = FAM.getResult<DependenceAnalysis>(F);
+ for (Loop *L : LI.getTopLevelLoops())
+ if (std::unique_ptr<CacheCost> CC =
+ getCacheCostImpl(*L, LI, SE, TTI, AA, DI, /*TRT=*/std::nullopt))
+ OS << *CC;
return PreservedAnalyses::all();
}
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 7ced179b78c11..7bc0f71f106d3 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -526,6 +526,7 @@ FUNCTION_PASS("print<func-properties>", FunctionPropertiesPrinterPass(errs()))
FUNCTION_PASS("print<inline-cost>", InlineCostAnnotationPrinterPass(errs()))
FUNCTION_PASS("print<lazy-value-info>", LazyValueInfoPrinterPass(errs()))
FUNCTION_PASS("print<loops>", LoopPrinterPass(errs()))
+FUNCTION_PASS("print<loop-cache-cost>", LoopCachePrinterPass(errs()))
FUNCTION_PASS("print<memoryssa-walker>", MemorySSAWalkerPrinterPass(errs()))
FUNCTION_PASS("print<phi-values>", PhiValuesPrinterPass(errs()))
FUNCTION_PASS("print<postdomtree>", PostDominatorTreePrinterPass(errs()))
@@ -800,7 +801,6 @@ LOOP_PASS("print", PrintLoopPass(errs()))
LOOP_PASS("print<ddg>", DDGAnalysisPrinterPass(errs()))
LOOP_PASS("print<hash-recognize>", HashRecognizePrinterPass(errs()))
LOOP_PASS("print<iv-users>", IVUsersPrinterPass(errs()))
-LOOP_PASS("print<loop-cache-cost>", LoopCachePrinterPass(errs()))
LOOP_PASS("print<loopnest>", LoopNestPrinterPass(errs()))
#undef LOOP_PASS
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/LoopnestFixedSize.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/LoopnestFixedSize.ll
index 02b09c0b3c684..2dc7a2bfeee51 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/LoopnestFixedSize.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/LoopnestFixedSize.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64"
@@ -6,9 +7,6 @@ target triple = "powerpc64le-unknown-linux-gnu"
; Check delinearization in loop cache analysis can handle fixed-size arrays.
; The IR is copied from llvm/test/Analysis/DependenceAnalysis/SimpleSIVNoValidityCheckFixedSize.ll
-; CHECK: Loop 'for.body' has cost = 4186116
-; CHECK-NEXT: Loop 'for.body4' has cost = 130944
-
;; #define N 1024
;; #define M 2048
;; void t1(int a[N][M]) {
@@ -18,6 +16,10 @@ target triple = "powerpc64le-unknown-linux-gnu"
;; }
define void @t1(ptr %a) {
+; CHECK-LABEL: 't1'
+; CHECK-NEXT: Loop 'for.body' has cost = 4186116
+; CHECK-NEXT: Loop 'for.body4' has cost = 130944
+;
entry:
br label %for.body
@@ -47,11 +49,11 @@ for.end13: ; preds = %for.inc11
ret void
}
-
-; CHECK: Loop 'for.body' has cost = 4186116
-; CHECK-NEXT: Loop 'for.body4' has cost = 130944
-
define void @t2(ptr %a) {
+; CHECK-LABEL: 't2'
+; CHECK-NEXT: Loop 'for.body' has cost = 4186116
+; CHECK-NEXT: Loop 'for.body4' has cost = 130944
+;
entry:
br label %for.body
@@ -83,12 +85,6 @@ for.end13: ; preds = %for.inc11
declare ptr @func_with_returned_arg(ptr returned %arg)
-; CHECK: Loop 'for.body' has cost = 2305843009213693951.75
-; CHECK-NEXT: Loop 'for.body4' has cost = 16762927104000000
-; CHECK-NEXT: Loop 'for.body8' has cost = 130960368000000
-; CHECK-NEXT: Loop 'for.body12' has cost = 1047682944000
-; CHECK-NEXT: Loop 'for.body16' has cost = 32772096000
-
;; #define N 128
;; #define M 2048
;; void t3(int a[][N][N][N][M]) {
@@ -101,6 +97,13 @@ declare ptr @func_with_returned_arg(ptr returned %arg)
;; }
define void @t3(ptr %a) {
+; CHECK-LABEL: 't3'
+; CHECK-NEXT: Loop 'for.body' has cost = 2305843009213693951.75
+; CHECK-NEXT: Loop 'for.body4' has cost = 16762927104000000
+; CHECK-NEXT: Loop 'for.body8' has cost = 130960368000000
+; CHECK-NEXT: Loop 'for.body12' has cost = 1047682944000
+; CHECK-NEXT: Loop 'for.body16' has cost = 32772096000
+;
entry:
br label %for.body
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost-m32.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost-m32.ll
index df32a406d2ba3..552e1b7f185ac 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost-m32.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost-m32.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "E-m:a-i64:64-p:32:32-n32-S128-v256:256:256-v512:512:512"
@@ -6,11 +7,12 @@ target triple = "powerpc-ibm-aix7.2.0.0"
; Check IndexedReference::computeRefCost can handle type differences between
; CacheLineSize and Numerator
-; CHECK: Loop '_loop_1_do_' has cost = 1
-
%_elem_type_of_v = type <{ i32 }>
define signext i32 @foo(ptr %v) {
+; CHECK-LABEL: 'foo'
+; CHECK-NEXT: Loop '_loop_1_do_' has cost = 1
+;
_entry:
br label %_loop_1_do_
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost.ll
index 7275d04c92b47..ba02acaa47792 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/compute-cost.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64"
@@ -6,12 +7,13 @@ target triple = "powerpc64le-unknown-linux-gnu"
; Check IndexedReference::computeRefCost can handle type differences between
; Stride and TripCount
-; CHECK: Loop 'for.cond' has cost = 64
-
%struct._Handleitem = type { ptr }
define void @handle_to_ptr(ptr %blocks) {
; Preheader:
+; CHECK-LABEL: 'handle_to_ptr'
+; CHECK-NEXT: Loop 'for.cond' has cost = 64
+;
entry:
br label %for.cond
@@ -36,13 +38,14 @@ for.end: ; preds = %for.cond
; Check IndexedReference::computeRefCost can handle type differences between
; Coeff and ElemSize.
-; CHECK: Loop 'for.cond' has cost = 100000000
-; CHECK: Loop 'for.cond1' has cost = 1000000
-; CHECK: Loop 'for.cond5' has cost = 40000
-
@data = external dso_local global [2 x [4 x [18 x i32]]], align 1
define dso_local void @handle_to_ptr_2(i1 %b0, i1 %b1, i1 %b2) {
+; CHECK-LABEL: 'handle_to_ptr_2'
+; CHECK-NEXT: Loop 'for.cond' has cost = 100000000
+; CHECK-NEXT: Loop 'for.cond1' has cost = 1000000
+; CHECK-NEXT: Loop 'for.cond5' has cost = 40000
+;
entry:
br label %for.cond
@@ -84,10 +87,11 @@ for.end19:
; Check IndexedReference::computeRefCost can handle negative stride
-; CHECK: Loop 'for.neg.cond' has cost = 64
-
define void @handle_to_ptr_neg_stride(ptr %blocks) {
; Preheader:
+; CHECK-LABEL: 'handle_to_ptr_neg_stride'
+; CHECK-NEXT: Loop 'for.neg.cond' has cost = 64
+;
entry:
br label %for.neg.cond
@@ -118,8 +122,10 @@ for.neg.end: ; preds = %for.neg.cond
; access functions. When this is fixed this testcase should have a cost
; approximately 2x higher.
-; CHECK: Loop 'for.cond2' has cost = 2561
define void @Test2(ptr %B) {
+; CHECK-LABEL: 'Test2'
+; CHECK-NEXT: Loop 'for.cond2' has cost = 2561
+;
entry:
br label %for.cond2
@@ -148,8 +154,10 @@ for.end: ; preds = %for.cond
; for (i = 40960; i > 0; i--)
; C[i] = C[i];
-; CHECK: Loop 'for.cond3' has cost = 2561
define void @Test3(ptr %C) {
+; CHECK-LABEL: 'Test3'
+; CHECK-NEXT: Loop 'for.cond3' has cost = 2561
+;
entry:
br label %for.cond3
@@ -177,8 +185,10 @@ for.end: ; preds = %for.cond
; for (i = 0; i < 40960; i++)
; D[i] = D[i];
-; CHECK: Loop 'for.cond4' has cost = 2561
define void @Test4(ptr %D) {
+; CHECK-LABEL: 'Test4'
+; CHECK-NEXT: Loop 'for.cond4' has cost = 2561
+;
entry:
br label %for.cond4
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/loads-store.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/loads-store.ll
index efb1d907605a8..919715c649142 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/loads-store.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/loads-store.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64"
@@ -10,11 +11,12 @@ target triple = "powerpc64le-unknown-linux-gnu"
; A[i][k][j] += B[i][k][j] + C[i][j][k];
; }
-; CHECK: Loop 'for.i' has cost = 3000000
-; CHECK-NEXT: Loop 'for.k' has cost = 2040000
-; CHECK-NEXT: Loop 'for.j' has cost = 1080000
-
define void @foo(i64 %n, i64 %m, i64 %o, ptr %A, ptr %B, ptr %C) {
+; CHECK-LABEL: 'foo'
+; CHECK-NEXT: Loop 'for.i' has cost = 300000000
+; CHECK-NEXT: Loop 'for.k' has cost = 2040000
+; CHECK-NEXT: Loop 'for.j' has cost = 1080000
+;
entry:
%cmp32 = icmp sgt i64 %n, 0
%cmp230 = icmp sgt i64 %m, 0
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/matmul.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/matmul.ll
index 0e8a25ffb1cac..7680eddcb47f8 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/matmul.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/matmul.ll
@@ -1,20 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64"
target triple = "powerpc64le-unknown-linux-gnu"
; void matmul(long n, long m, long o, int A[n][m], int B[n][m], int C[n]) {
-; for (long i = 0; i < n; i++)
-; for (long j = 0; j < m; j++)
-; for (long k = 0; k < o; k++)
+; for (long i = 0; i < n; i++)
+; for (long j = 0; j < m; j++)
+; for (long k = 0; k < o; k++)
; C[i][j] = C[i][j] + A[i][k] * B[k][j];
; }
-; CHECK:Loop 'for.i' has cost = 2010000
-; CHECK-NEXT:Loop 'for.k' has cost = 1050000
-; CHECK-NEXT:Loop 'for.j' has cost = 90000
-
define void @matmul(i64 %n, i64 %m, i64 %o, ptr %A, ptr %B, ptr %C) {
+; CHECK-LABEL: 'matmul'
+; CHECK-NEXT: Loop 'for.i' has cost = 2010000
+; CHECK-NEXT: Loop 'for.k' has cost = 1050000
+; CHECK-NEXT: Loop 'for.j' has cost = 90000
+;
entry:
br label %for.i
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/matvecmul.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/matvecmul.ll
index bf5425881ce3b..0368ac3a2a770 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/matvecmul.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/matvecmul.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64"
@@ -6,7 +7,7 @@ target triple = "powerpc64le-unknown-linux-gnu"
; void matvecmul(const double *__restrict y, const double * __restrict x, const double * __restrict b,
; const int * __restrict nb, const int * __restrict nx, const int * __restrict ny, const int * __restrict nz) {
;
-; for (int k=1;k<nz,++k)
+; for (int k=1;k<nz,++k)
; for (int j=1;j<ny,++j)
; for (int i=1;i<nx,++i)
; for (int l=1;l<nb,++l)
@@ -14,17 +15,18 @@ target triple = "powerpc64le-unknown-linux-gnu"
; y[k+1][j][i][l] = y[k+1][j][i][l] + b[k][j][i][m][l]*x[k][j][i][m]
; }
-; CHECK: Loop 'k_loop' has cost = 10200000000000000
-; CHECK-NEXT: Loop 'j_loop' has cost = 102000000000000
-; CHECK-NEXT: Loop 'i_loop' has cost = 1020000000000
-; CHECK-NEXT: Loop 'm_loop' has cost = 10800000000
-; CHECK-NEXT: Loop 'l_loop' has cost = 1500000000
-
%_elem_type_of_double = type <{ double }>
; Function Attrs: norecurse nounwind
define void @mat_vec_mpy(ptr noalias %y, ptr noalias readonly %x,
- ptr noalias readonly %b, ptr noalias readonly %nb, ptr noalias readonly %nx,
+; CHECK-LABEL: 'mat_vec_mpy'
+; CHECK-NEXT: Loop 'k_loop' has cost = 10200000000000000
+; CHECK-NEXT: Loop 'j_loop' has cost = 102000000000000
+; CHECK-NEXT: Loop 'i_loop' has cost = 1020000000000
+; CHECK-NEXT: Loop 'm_loop' has cost = 10800000000
+; CHECK-NEXT: Loop 'l_loop' has cost = 1500000000
+;
+ ptr noalias readonly %b, ptr noalias readonly %nb, ptr noalias readonly %nx,
ptr noalias readonly %ny, ptr noalias readonly %nz) {
mat_times_vec_entry:
%_ind_val = load i32, ptr %nb, align 4
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/multi-store.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/multi-store.ll
index b6c2497d45b9b..3491f2a4062f6 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/multi-store.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/multi-store.ll
@@ -1,14 +1,11 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512"
target triple = "powerpc64le-unknown-linux-gnu"
-; CHECK: Loop 'for.j' has cost = 201000000
-; CHECK-NEXT: Loop 'for.i' has cost = 102000000
-; CHECK-NEXT: Loop 'for.k' has cost = 120000
-
-;; Test to make sure when we have multiple conflicting access patterns, the
-;; chosen loop configuration favours the majority of those accesses.
+;; Test to make sure when we have multiple conflicting access patterns, the
+;; chosen loop configuration favours the majority of those accesses.
;; For example this nest should be ordered as j-i-k.
;; for (int i = 0; i < n; i++)
;; for (int j = 0; j < n; j++)
@@ -16,9 +13,14 @@ target triple = "powerpc64le-unknown-linux-gnu"
;; A[i][j][k] = 1;
;; B[j][i][k] = 2;
;; C[j][i][k] = 3;
-;; }
+;; }
define void @foo(i32 noundef signext %n, ptr noalias noundef %A, ptr noalias noundef %B, ptr noalias noundef %C) {
+; CHECK-LABEL: 'foo'
+; CHECK-NEXT: Loop 'for.j' has cost = 201000000
+; CHECK-NEXT: Loop 'for.i' has cost = 102000000
+; CHECK-NEXT: Loop 'for.k' has cost = 120000
+;
entry:
%0 = zext i32 %n to i64
%1 = zext i32 %n to i64
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/single-store.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/single-store.ll
index 9aa048489bd38..1d2c87405590a 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/single-store.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/single-store.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64"
@@ -10,11 +11,12 @@ target triple = "powerpc64le-unknown-linux-gnu"
; A[2*i+3][3*j-4][2*k+7] = 1;
; }
-; CHECK: Loop 'for.i' has cost = 100000000
-; CHECK-NEXT: Loop 'for.j' has cost = 1000000
-; CHECK-NEXT: Loop 'for.k' has cost = 70000
-
define void @foo(i64 %n, i64 %m, i64 %o, ptr %A) {
+; CHECK-LABEL: 'foo'
+; CHECK-NEXT: Loop 'for.i' has cost = 100000000
+; CHECK-NEXT: Loop 'for.j' has cost = 1000000
+; CHECK-NEXT: Loop 'for.k' has cost = 70000
+;
entry:
%cmp32 = icmp sgt i64 %n, 0
%cmp230 = icmp sgt i64 %m, 0
@@ -88,11 +90,12 @@ for.end: ; preds = %for.end.loopexit, %
; A[2*i+3][2*j-4][2*k+7] = 1;
; }
-; CHECK: Loop 'for.i' has cost = 100000000
-; CHECK-NEXT: Loop 'for.j' has cost = 1000000
-; CHECK-NEXT: Loop 'for.k' has cost = 70000
-
define void @foo2(i64 %n, i64 %m, i64 %o, ptr %A) {
+; CHECK-LABEL: 'foo2'
+; CHECK-NEXT: Loop 'for.i' has cost = 100000000
+; CHECK-NEXT: Loop 'for.j' has cost = 1000000
+; CHECK-NEXT: Loop 'for.k' has cost = 70000
+;
entry:
%cmp32 = icmp sgt i64 %n, 0
%cmp230 = icmp sgt i64 %m, 0
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll
index 458f87a83527b..ed04cd8da78d9 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/PowerPC/stencil.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-n32:64"
@@ -8,13 +9,14 @@ target triple = "powerpc64le-unknown-linux-gnu"
; for (long j = 0; j < m; j++) {
; A[i][j] = A[i][j+1] + B[i-1][j] + B[i+1][j+1] + C[i];
; A[i][j] += B[i][i];
-; }
+; }
; }
-; CHECK: Loop 'for.i' has cost = 20400
-; CHECK-NEXT: Loop 'for.j' has cost = 900
-
define void @foo(i64 %n, i64 %m, ptr %A, ptr %B, ptr %C) {
+; CHECK-LABEL: 'foo'
+; CHECK-NEXT: Loop 'for.i' has cost = 20400
+; CHECK-NEXT: Loop 'for.j' has cost = 900
+;
entry:
%cmp32 = icmp sgt i64 %n, 0
%cmp230 = icmp sgt i64 %m, 0
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/compute-cost.ll b/llvm/test/Analysis/LoopCacheAnalysis/compute-cost.ll
index 205cd851fce0d..e5a0b55ffff45 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/compute-cost.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/compute-cost.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -cache-line-size=32 -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck -check-prefix=SMALLER-CACHELINE %s
; RUN: opt < %s -cache-line-size=256 -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck -check-prefix=LARGER-CACHELINE %s
@@ -11,12 +12,16 @@
; Round costs up to the nearest whole number i.e. in 'for.cond5' cost is calculated 12.5 and
; it makes more sense to say 13 cache lines are used rather than 12 cache lines.
-; SMALLER-CACHELINE: Loop 'for.cond' has cost = 256
-; LARGER-CACHELINE: Loop 'for.cond' has cost = 32
%struct._Handleitem = type { ptr }
define void @handle_to_ptr(ptr %blocks) {
; Preheader:
+; SMALLER-CACHELINE-LABEL: 'handle_to_ptr'
+; SMALLER-CACHELINE-NEXT: Loop 'for.cond' has cost = 256
+;
+; LARGER-CACHELINE-LABEL: 'handle_to_ptr'
+; LARGER-CACHELINE-NEXT: Loop 'for.cond' has cost = 32
+;
entry:
br label %for.cond
@@ -41,15 +46,19 @@ for.end: ; preds = %for.cond
; Check IndexedReference::computeRefCost can handle type differences between
; Coeff and ElemSize.
-; SMALLER-CACHELINE: Loop 'for.cond' has cost = 100000000
-; SMALLER-CACHELINE: Loop 'for.cond1' has cost = 1000000
-; SMALLER-CACHELINE: Loop 'for.cond5' has cost = 130000
-; LARGER-CACHELINE: Loop 'for.cond' has cost = 100000000
-; LARGER-CACHELINE: Loop 'for.cond1' has cost = 1000000
-; LARGER-CACHELINE: Loop 'for.cond5' has cost = 20000
@data = external dso_local global [2 x [4 x [18 x i32]]], align 1
define dso_local void @handle_to_ptr_2(i1 %b0, i1 %b1, i1 %b2) {
+; SMALLER-CACHELINE-LABEL: 'handle_to_ptr_2'
+; SMALLER-CACHELINE-NEXT: Loop 'for.cond' has cost = 100000000
+; SMALLER-CACHELINE-NEXT: Loop 'for.cond1' has cost = 1000000
+; SMALLER-CACHELINE-NEXT: Loop 'for.cond5' has cost = 130000
+;
+; LARGER-CACHELINE-LABEL: 'handle_to_ptr_2'
+; LARGER-CACHELINE-NEXT: Loop 'for.cond' has cost = 100000000
+; LARGER-CACHELINE-NEXT: Loop 'for.cond1' has cost = 1000000
+; LARGER-CACHELINE-NEXT: Loop 'for.cond5' has cost = 20000
+;
entry:
br label %for.cond
@@ -91,10 +100,14 @@ for.end19:
; Check IndexedReference::computeRefCost can handle negative stride
-; SMALLER-CACHELINE: Loop 'for.neg.cond' has cost = 256
-; LARGER-CACHELINE: Loop 'for.neg.cond' has cost = 32
define void @handle_to_ptr_neg_stride(ptr %blocks) {
; Preheader:
+; SMALLER-CACHELINE-LABEL: 'handle_to_ptr_neg_stride'
+; SMALLER-CACHELINE-NEXT: Loop 'for.neg.cond' has cost = 256
+;
+; LARGER-CACHELINE-LABEL: 'handle_to_ptr_neg_stride'
+; LARGER-CACHELINE-NEXT: Loop 'for.neg.cond' has cost = 32
+;
entry:
br label %for.neg.cond
@@ -125,9 +138,13 @@ for.neg.end: ; preds = %for.neg.cond
; access functions. When this is fixed this testcase should have a cost
; approximately 2x higher.
-; SMALLER-CACHELINE: Loop 'for.cond2' has cost = 10241
-; LARGER-CACHELINE: Loop 'for.cond2' has cost = 1281
define void @Test2(ptr %B) {
+; SMALLER-CACHELINE-LABEL: 'Test2'
+; SMALLER-CACHELINE-NEXT: Loop 'for.cond2' has cost = 10241
+;
+; LARGER-CACHELINE-LABEL: 'Test2'
+; LARGER-CACHELINE-NEXT: Loop 'for.cond2' has cost = 1281
+;
entry:
br label %for.cond2
@@ -156,9 +173,13 @@ for.end: ; preds = %for.cond
; for (i = 40960; i > 0; i--)
; C[i] = C[i];
-; SMALLER-CACHELINE: Loop 'for.cond3' has cost = 10241
-; LARGER-CACHELINE: Loop 'for.cond3' has cost = 1281
define void @Test3(ptr %C) {
+; SMALLER-CACHELINE-LABEL: 'Test3'
+; SMALLER-CACHELINE-NEXT: Loop 'for.cond3' has cost = 10241
+;
+; LARGER-CACHELINE-LABEL: 'Test3'
+; LARGER-CACHELINE-NEXT: Loop 'for.cond3' has cost = 1281
+;
entry:
br label %for.cond3
@@ -186,9 +207,13 @@ for.end: ; preds = %for.cond
; for (i = 0; i < 40960; i++)
; D[i] = D[i];
-; SMALLER-CACHELINE: Loop 'for.cond4' has cost = 10241
-; LARGER-CACHELINE: Loop 'for.cond4' has cost = 1281
define void @Test4(ptr %D) {
+; SMALLER-CACHELINE-LABEL: 'Test4'
+; SMALLER-CACHELINE-NEXT: Loop 'for.cond4' has cost = 10241
+;
+; LARGER-CACHELINE-LABEL: 'Test4'
+; LARGER-CACHELINE-NEXT: Loop 'for.cond4' has cost = 1281
+;
entry:
br label %for.cond4
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/interchange-cost-beneficial.ll b/llvm/test/Analysis/LoopCacheAnalysis/interchange-cost-beneficial.ll
index 3086224c58204..29bf54b897ad7 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/interchange-cost-beneficial.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/interchange-cost-beneficial.ll
@@ -1,9 +1,10 @@
-; RUN: opt < %s -cache-line-size=64 -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -cache-line-size=64 -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
-;; This test checks the effect of rounding cache cost to 1 when it is
+;; This test checks the effect of rounding cache cost to 1 when it is
;; evaluated to 0 because at least 1 cache line is accessed by the loopnest.
;; It does not make sense to output that zero cache lines are used.
-;; The cost of reference group for B[j], C[j], D[j] and E[j] were
+;; The cost of reference group for B[j], C[j], D[j] and E[j] were
;; calculted 0 before but now they are 1 which makes each loop cost more reasonable.
;
; void test(int n, int m, int o, int A[2][3], int B[2], int C[2], int D[2], int E[2]) {
@@ -16,11 +17,11 @@
; E[j] = 1
; }
-; CHECK: Loop 'for.j' has cost = 18
-; CHECK-NEXT: Loop 'for.i' has cost = 10
-
define void @test(ptr %A, ptr %B, ptr %C, ptr %D, ptr %E) {
-
+; CHECK-LABEL: 'test'
+; CHECK-NEXT: Loop 'for.j' has cost = 18
+; CHECK-NEXT: Loop 'for.i' has cost = 10
+;
entry:
br label %for.i.preheader.split
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/interchange-refcost-overflow.ll b/llvm/test/Analysis/LoopCacheAnalysis/interchange-refcost-overflow.ll
index 90dd96d322e92..f7113798d8acb 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/interchange-refcost-overflow.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/interchange-refcost-overflow.ll
@@ -1,4 +1,5 @@
-; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
; For a loop with a very large iteration count, make sure the cost
; calculation does not overflow:
@@ -10,13 +11,14 @@
; A[c][d][e] = 0;
; }
-; CHECK: Loop 'outer.loop' has cost = 2305843009213693951.75
-; CHECK: Loop 'middle.loop' has cost = 2305843009213693951.75
-; CHECK: Loop 'inner.loop' has cost = 2305843009213693951.75
-
@A = local_unnamed_addr global [11 x [11 x [11 x i32]]] zeroinitializer, align 16
define void @foo() {
+; CHECK-LABEL: 'foo'
+; CHECK-NEXT: Loop 'outer.loop' has cost = 2305843009213693951.75
+; CHECK-NEXT: Loop 'middle.loop' has cost = 2305843009213693951.75
+; CHECK-NEXT: Loop 'inner.loop' has cost = 2305843009213693951.75
+;
entry:
br label %outer.loop
diff --git a/llvm/test/Analysis/LoopCacheAnalysis/partially-perfect-nest.ll b/llvm/test/Analysis/LoopCacheAnalysis/partially-perfect-nest.ll
index b9ad82735c2f0..c788214dd30c6 100644
--- a/llvm/test/Analysis/LoopCacheAnalysis/partially-perfect-nest.ll
+++ b/llvm/test/Analysis/LoopCacheAnalysis/partially-perfect-nest.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
; RUN: opt < %s -cache-line-size=64 -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
;; FIXME: For a forked nest getInnerMostLoop() fails to
@@ -12,13 +13,14 @@
;; FIXME: only the 'k/kk' sub-nest is costed, 'a.i' (a fork) should not have a
;; cost, and 'a.j'/'a.jj' are wrongly costed as loop-invariant.
-; CHECK: Loop 'a.k' has cost = 10000000000
-; CHECK-NEXT: Loop 'a.kk' has cost = 1300000000
-; CHECK-NEXT: Loop 'a.i' has cost = 100000000
-; CHECK-NEXT: Loop 'a.j' has cost = 100000000
-; CHECK-NEXT: Loop 'a.jj' has cost = 100000000
-
define void @fork_at_top(ptr %A, ptr %B) {
+; CHECK-LABEL: 'fork_at_top'
+; CHECK-NEXT: Loop 'a.k' has cost = 10000000000
+; CHECK-NEXT: Loop 'a.kk' has cost = 1300000000
+; CHECK-NEXT: Loop 'a.i' has cost = 100000000
+; CHECK-NEXT: Loop 'a.j' has cost = 100000000
+; CHECK-NEXT: Loop 'a.jj' has cost = 100000000
+;
entry:
br label %a.i
a.i:
@@ -68,12 +70,13 @@ exit:
;; FIXME: only the 'l' sub-nest is costed, and the fork loops 'b.i'/'b.j' should
;; not have a cost.
-; CHECK: Loop 'b.l' has cost = 13000000
-; CHECK-NEXT: Loop 'b.i' has cost = 1000000
-; CHECK-NEXT: Loop 'b.j' has cost = 1000000
-; CHECK-NEXT: Loop 'b.k' has cost = 1000000
-
define void @fork_in_middle(ptr %C, ptr %D) {
+; CHECK-LABEL: 'fork_in_middle'
+; CHECK-NEXT: Loop 'b.l' has cost = 13000000
+; CHECK-NEXT: Loop 'b.i' has cost = 1000000
+; CHECK-NEXT: Loop 'b.j' has cost = 1000000
+; CHECK-NEXT: Loop 'b.k' has cost = 1000000
+;
entry:
br label %b.i
b.i:
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index fd8ff9f576da1..8eb3249c3f6c2 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -40,6 +40,7 @@
"Dependence Analysis",
"Delinearization",
"Loop Access Analysis",
+ "Loop Cache Analysis",
"Scalar Evolution Analysis",
"Scalar Evolution Division",
}
More information about the llvm-commits
mailing list