1 ; RUN: opt < %s -analyze -delinearize | FileCheck %s
3 ; #define MR(mt,n,r,c,d) mt->m[(n) * mt->mrows * mt->mcols * mt->mdeps + (r) * mt->mcols* mt->mdeps + (c) * mt->mdeps + (d)]
13 ; typedef struct Mat Matrix;
15 ; void jacobi(int nn, Matrix* a, Matrix* p)
17 ; long i, j, k, max,jmax,kmax;
19 ; p_rows_sub = p->mrows - 1;
20 ; p_cols_sub = p->mcols - 1;
21 ; p_deps_sub = p->mdeps - 1;
23 ; for(i = 1; i < p_rows_sub; i++)
24 ; for(j = 1; j < p_cols_sub; j++)
25 ; for(k = 1; k < p_deps_sub; k++)
26 ; MR(a,0,i,j,k) = i + j + k;
29 ; AddRec: {{{(4 + (4 * (sext i32 %a.deps to i64) * (1 + (sext i32 %a.cols to i64))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>,+,(4 * (sext i32 %a.deps to i64))}<%for.j>,+,4}<%for.k>
30 ; CHECK: Base offset: %a.base
31 ; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.cols to i64)][(sext i32 %a.deps to i64)] with elements of sizeof(float) bytes.
32 ; CHECK: ArrayRef[{1,+,1}<nuw><nsw><%for.i>][{1,+,1}<nuw><nsw><%for.j>][{1,+,1}<nuw><nsw><%for.k>]
34 ; AddRec: {{(-4 + (4 * (sext i32 (-1 + %p.deps) to i64)) + (4 * (sext i32 %a.deps to i64) * (1 + (sext i32 %a.cols to i64))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>,+,(4 * (sext i32 %a.deps to i64))}<%for.j>
35 ; CHECK: Base offset: %a.base
36 ; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.deps to i64)] with elements of sizeof(float) bytes.
37 ; CHECK: ArrayRef[{(1 + (sext i32 %a.cols to i64)),+,(sext i32 %a.cols to i64)}<%for.i>][{(-1 + (sext i32 (-1 + %p.deps) to i64)),+,(sext i32 %a.deps to i64)}<%for.j>]
39 ; AddRec: {(-4 + (4 * (sext i32 (-1 + %p.deps) to i64)) + ((sext i32 %a.deps to i64) * (-4 + (4 * (sext i32 (-1 + %p.cols) to i64)) + (4 * (sext i32 %a.cols to i64)))) + %a.base),+,(4 * (sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>
40 ; CHECK: Base offset: %a.base
41 ; CHECK: ArrayDecl[UnknownSize] with elements of sizeof(float) bytes.
42 ; CHECK: ArrayRef[{(-1 + (sext i32 (-1 + %p.deps) to i64) + ((sext i32 %a.deps to i64) * (-1 + (sext i32 (-1 + %p.cols) to i64) + (sext i32 %a.cols to i64)))),+,((sext i32 %a.deps to i64) * (sext i32 %a.cols to i64))}<%for.i>]
44 %struct.Mat = type { float*, i32, i32, i32, i32 }
46 define void @jacobi(i32 %nn, %struct.Mat* nocapture %a, %struct.Mat* nocapture %p) nounwind uwtable {
48 %p.rows.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 2
49 %p.rows = load i32* %p.rows.ptr
50 %p.rows.sub = add i32 %p.rows, -1
51 %p.rows.sext = sext i32 %p.rows.sub to i64
52 %p.cols.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 3
53 %p.cols = load i32* %p.cols.ptr
54 %p.cols.sub = add i32 %p.cols, -1
55 %p.cols.sext = sext i32 %p.cols.sub to i64
56 %p.deps.ptr = getelementptr inbounds %struct.Mat* %p, i64 0, i32 4
57 %p.deps = load i32* %p.deps.ptr
58 %p.deps.sub = add i32 %p.deps, -1
59 %p.deps.sext = sext i32 %p.deps.sub to i64
60 %a.cols.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 3
61 %a.cols = load i32* %a.cols.ptr
62 %a.deps.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 4
63 %a.deps = load i32* %a.deps.ptr
64 %a.base.ptr = getelementptr inbounds %struct.Mat* %a, i64 0, i32 0
65 %a.base = load float** %a.base.ptr, align 8
68 for.i: ; preds = %for.i.inc, %entry
69 %i = phi i64 [ %i.inc, %for.i.inc ], [ 1, %entry ]
72 for.j: ; preds = %for.j.inc, %for.i
73 %j = phi i64 [ %j.inc, %for.j.inc ], [ 1, %for.i ]
74 %a.cols.sext = sext i32 %a.cols to i64
75 %a.deps.sext = sext i32 %a.deps to i64
78 for.k: ; preds = %for.k, %for.j
79 %k = phi i64 [ 1, %for.j ], [ %k.inc, %for.k ]
80 %tmp1 = mul nsw i64 %a.cols.sext, %i
81 %tmp2 = add i64 %tmp1, %j
82 %tmp3 = mul i64 %tmp2, %a.deps.sext
83 %tmp4 = add nsw i64 %k, %tmp3
84 %arrayidx = getelementptr inbounds float* %a.base, i64 %tmp4
85 store float 1.000000e+00, float* %arrayidx
86 %k.inc = add nsw i64 %k, 1
87 %k.exitcond = icmp eq i64 %k.inc, %p.deps.sext
88 br i1 %k.exitcond, label %for.j.inc, label %for.k
90 for.j.inc: ; preds = %for.k
91 %j.inc = add nsw i64 %j, 1
92 %j.exitcond = icmp eq i64 %j.inc, %p.cols.sext
93 br i1 %j.exitcond, label %for.i.inc, label %for.j
95 for.i.inc: ; preds = %for.j.inc
96 %i.inc = add nsw i64 %i, 1
97 %i.exitcond = icmp eq i64 %i.inc, %p.rows.sext
98 br i1 %i.exitcond, label %end, label %for.i
100 end: ; preds = %for.i.inc