1; RUN: opt < %s -cache-line-size=64 -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s 2 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. 8; 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++) 12; A[j][i] = 1; 13; B[j] = 1; 14; C[j] = 1; 15; D[j] = 1 16; E[j] = 1 17; } 18 19; CHECK: Loop 'for.j' has cost = 18 20; CHECK-NEXT: Loop 'for.i' has cost = 10 21 22define void @test(ptr %A, ptr %B, ptr %C, ptr %D, ptr %E) { 23 24entry: 25 br label %for.i.preheader.split 26 27for.i.preheader.split: ; preds = %for.i.preheader 28 br label %for.i 29 30for.i: ; preds = %for.inci, %for.i.preheader.split 31 %i = phi i64 [ %inci, %for.inci ], [ 0, %for.i.preheader.split ] 32 br label %for.j 33 34for.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 51 52for.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 56 57for.end.loopexit: ; preds = %for.inci 58 br label %for.end 59 60for.end: ; preds = %for.end.loopexit, %for.cond1.preheader.lr.ph, %entry 61 ret void 62} 63