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 4 bytes.
32 ; CHECK: ArrayRef[{1,+,1}<nuw><nsw><%for.i>][{1,+,1}<nuw><nsw><%for.j>][{1,+,1}<nuw><nsw><%for.k>]
34 %struct.Mat = type { float*, i32, i32, i32, i32 }
36 define void @jacobi(i32 %nn, %struct.Mat* nocapture %a, %struct.Mat* nocapture %p) nounwind uwtable {
38 %p.rows.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %p, i64 0, i32 2
39 %p.rows = load i32, i32* %p.rows.ptr
40 %p.rows.sub = add i32 %p.rows, -1
41 %p.rows.sext = sext i32 %p.rows.sub to i64
42 %p.cols.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %p, i64 0, i32 3
43 %p.cols = load i32, i32* %p.cols.ptr
44 %p.cols.sub = add i32 %p.cols, -1
45 %p.cols.sext = sext i32 %p.cols.sub to i64
46 %p.deps.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %p, i64 0, i32 4
47 %p.deps = load i32, i32* %p.deps.ptr
48 %p.deps.sub = add i32 %p.deps, -1
49 %p.deps.sext = sext i32 %p.deps.sub to i64
50 %a.cols.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %a, i64 0, i32 3
51 %a.cols = load i32, i32* %a.cols.ptr
52 %a.deps.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %a, i64 0, i32 4
53 %a.deps = load i32, i32* %a.deps.ptr
54 %a.base.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %a, i64 0, i32 0
55 %a.base = load float*, float** %a.base.ptr, align 8
58 for.i: ; preds = %for.i.inc, %entry
59 %i = phi i64 [ %i.inc, %for.i.inc ], [ 1, %entry ]
62 for.j: ; preds = %for.j.inc, %for.i
63 %j = phi i64 [ %j.inc, %for.j.inc ], [ 1, %for.i ]
64 %a.cols.sext = sext i32 %a.cols to i64
65 %a.deps.sext = sext i32 %a.deps to i64
68 for.k: ; preds = %for.k, %for.j
69 %k = phi i64 [ 1, %for.j ], [ %k.inc, %for.k ]
70 %tmp1 = mul nsw i64 %a.cols.sext, %i
71 %tmp2 = add i64 %tmp1, %j
72 %tmp3 = mul i64 %tmp2, %a.deps.sext
73 %tmp4 = add nsw i64 %k, %tmp3
74 %arrayidx = getelementptr inbounds float, float* %a.base, i64 %tmp4
75 store float 1.000000e+00, float* %arrayidx
76 %k.inc = add nsw i64 %k, 1
77 %k.exitcond = icmp eq i64 %k.inc, %p.deps.sext
78 br i1 %k.exitcond, label %for.j.inc, label %for.k
80 for.j.inc: ; preds = %for.k
81 %j.inc = add nsw i64 %j, 1
82 %j.exitcond = icmp eq i64 %j.inc, %p.cols.sext
83 br i1 %j.exitcond, label %for.i.inc, label %for.j
85 for.i.inc: ; preds = %for.j.inc
86 %i.inc = add nsw i64 %i, 1
87 %i.exitcond = icmp eq i64 %i.inc, %p.rows.sext
88 br i1 %i.exitcond, label %end, label %for.i
90 end: ; preds = %for.i.inc