brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 3086224 Raw
63 lines · plain
1; RUN: opt <  %s  -cache-line-size=64 -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck  %s2 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] = 116;        E[j] = 117; }18 19; CHECK: Loop 'for.j' has cost = 1820; CHECK-NEXT: Loop 'for.i' has cost = 1021 22define void @test(ptr %A, ptr %B, ptr %C, ptr %D, ptr %E) {23 24entry:25  br label %for.i.preheader.split26 27for.i.preheader.split:                            ; preds = %for.i.preheader28  br label %for.i29 30for.i:                                            ; preds = %for.inci, %for.i.preheader.split31  %i = phi i64 [ %inci, %for.inci ], [ 0, %for.i.preheader.split ]32  br label %for.j33 34for.j:                                            ; preds = %for.incj, %for.i35  %j = phi i64 [ %incj, %for.j ], [ 0, %for.i ]36  %mul_j = mul nsw i64 %j, 337  %index_j = add i64 %mul_j, %i38  %arrayidxA = getelementptr inbounds [2 x [ 3 x i32]], ptr %A, i64 %j, i64 %i39  store i32 1, ptr %arrayidxA, align 440  %arrayidxB = getelementptr inbounds i32, ptr %B, i64 %j41  store i32 1, ptr %arrayidxB, align 442  %arrayidxC = getelementptr inbounds i32, ptr %C, i64 %j43  store i32 1, ptr %arrayidxC, align 444  %arrayidxD = getelementptr inbounds i32, ptr %D, i64 %j45  store i32 1, ptr %arrayidxD, align 446  %arrayidxE = getelementptr inbounds i32, ptr %E, i64 %j47  store i32 1, ptr %arrayidxE, align 448  %incj = add nsw i64 %j, 149  %exitcond.us = icmp eq i64 %incj, 250  br i1 %exitcond.us, label %for.inci, label %for.j51 52for.inci:                                         ; preds = %for.incj53  %inci = add nsw i64 %i, 154  %exitcond55.us = icmp eq i64 %inci, 355  br i1 %exitcond55.us, label %for.end.loopexit, label %for.i56 57for.end.loopexit:                                 ; preds = %for.inci58  br label %for.end59 60for.end:                                          ; preds = %for.end.loopexit, %for.cond1.preheader.lr.ph, %entry61  ret void62}63