1 ; RUN: opt < %s -cache-line-size=64 -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
3 ;; This test checks the effect of rounding cache cost to 1 when it is
4 ;; evaluated to 0 because at least 1 cache line is accessed by the loopnest.
5 ;; It does not make sense to output that zero cache lines are used.
6 ;; The cost of reference group for B[j], C[j], D[j] and E[j] were
7 ;; calculted 0 before but now they are 1 which makes each loop cost more reasonable.
9 ; void test(int n, int m, int o, int A[2][3], int B[2], int C[2], int D[2], int E[2]) {
10 ; for (int i = 0; i < 3; i++)
11 ; for (int j = 0; j < 2; j++)
19 ; CHECK: Loop 'for.j' has cost = 18
20 ; CHECK-NEXT: Loop 'for.i' has cost = 10
22 define void @test(ptr %A, ptr %B, ptr %C, ptr %D, ptr %E) {
25 br label %for.i.preheader.split
27 for.i.preheader.split: ; preds = %for.i.preheader
30 for.i: ; preds = %for.inci, %for.i.preheader.split
31 %i = phi i64 [ %inci, %for.inci ], [ 0, %for.i.preheader.split ]
34 for.j: ; preds = %for.incj, %for.i
35 %j = phi i64 [ %incj, %for.j ], [ 0, %for.i ]
36 %mul_j = mul nsw i64 %j, 3
37 %index_j = add i64 %mul_j, %i
38 %arrayidxA = getelementptr inbounds [2 x [ 3 x i32]], ptr %A, i64 %j, i64 %i
39 store i32 1, ptr %arrayidxA, align 4
40 %arrayidxB = getelementptr inbounds i32, ptr %B, i64 %j
41 store i32 1, ptr %arrayidxB, align 4
42 %arrayidxC = getelementptr inbounds i32, ptr %C, i64 %j
43 store i32 1, ptr %arrayidxC, align 4
44 %arrayidxD = getelementptr inbounds i32, ptr %D, i64 %j
45 store i32 1, ptr %arrayidxD, align 4
46 %arrayidxE = getelementptr inbounds i32, ptr %E, i64 %j
47 store i32 1, ptr %arrayidxE, align 4
48 %incj = add nsw i64 %j, 1
49 %exitcond.us = icmp eq i64 %incj, 2
50 br i1 %exitcond.us, label %for.inci, label %for.j
52 for.inci: ; preds = %for.incj
53 %inci = add nsw i64 %i, 1
54 %exitcond55.us = icmp eq i64 %inci, 3
55 br i1 %exitcond55.us, label %for.end.loopexit, label %for.i
57 for.end.loopexit: ; preds = %for.inci
60 for.end: ; preds = %for.end.loopexit, %for.cond1.preheader.lr.ph, %entry