1 ; RUN: opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1 | FileCheck %s
3 target datalayout = "e-m:e-i64:64-n32:64"
4 target triple = "powerpc64le-unknown-linux-gnu"
6 ; void foo(long n, long m, long o, int A[n][m][o]) {
7 ; for (long i = 0; i < n; i++)
8 ; for (long j = 0; j < m; j++)
9 ; for (long k = 0; k < o; k++)
10 ; A[2*i+3][3*j-4][2*k+7] = 1;
13 ; CHECK-DAG: Loop 'for.i' has cost = 1000000
14 ; CHECK-DAG: Loop 'for.j' has cost = 1000000
15 ; CHECK-DAG: Loop 'for.k' has cost = 60000
17 define void @foo(i64 %n, i64 %m, i64 %o, i32* %A) {
19 %cmp32 = icmp sgt i64 %n, 0
20 %cmp230 = icmp sgt i64 %m, 0
21 %cmp528 = icmp sgt i64 %o, 0
22 br i1 %cmp32, label %for.cond1.preheader.lr.ph, label %for.end
24 for.cond1.preheader.lr.ph: ; preds = %entry
25 br i1 %cmp230, label %for.i.preheader, label %for.end
27 for.i.preheader: ; preds = %for.cond1.preheader.lr.ph
28 br i1 %cmp528, label %for.i.preheader.split, label %for.end
30 for.i.preheader.split: ; preds = %for.i.preheader
33 for.i: ; preds = %for.inci, %for.i.preheader.split
34 %i = phi i64 [ %inci, %for.inci ], [ 0, %for.i.preheader.split ]
36 %add9 = add nsw i64 %mul8, 3
37 %0 = mul i64 %add9, %m
41 for.j: ; preds = %for.incj, %for.i
42 %j = phi i64 [ %incj, %for.incj ], [ 0, %for.i ]
43 %mul7 = mul nsw i64 %j, 3
44 %tmp = add i64 %sub, %mul7
45 %tmp27 = mul i64 %tmp, %o
48 for.k: ; preds = %for.k, %for.j.us
49 %k = phi i64 [ 0, %for.j ], [ %inck, %for.k ]
51 %mul = mul nsw i64 %k, 2
52 %arrayidx.sum = add i64 %mul, 7
53 %arrayidx10.sum = add i64 %arrayidx.sum, %tmp27
54 %arrayidx11 = getelementptr inbounds i32, i32* %A, i64 %arrayidx10.sum
55 store i32 1, i32* %arrayidx11, align 4
57 %inck = add nsw i64 %k, 1
58 %exitcond.us = icmp eq i64 %inck, %o
59 br i1 %exitcond.us, label %for.incj, label %for.k
61 for.incj: ; preds = %for.k
62 %incj = add nsw i64 %j, 1
63 %exitcond54.us = icmp eq i64 %incj, %m
64 br i1 %exitcond54.us, label %for.inci, label %for.j
66 for.inci: ; preds = %for.incj
67 %inci = add nsw i64 %i, 1
68 %exitcond55.us = icmp eq i64 %inci, %n
69 br i1 %exitcond55.us, label %for.end.loopexit, label %for.i
71 for.end.loopexit: ; preds = %for.inci
74 for.end: ; preds = %for.end.loopexit, %for.cond1.preheader.lr.ph, %entry