1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -analyze -delinearize | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; #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)] 4*9880d681SAndroid Build Coastguard Worker; 5*9880d681SAndroid Build Coastguard Worker; struct Mat { 6*9880d681SAndroid Build Coastguard Worker; float* m; 7*9880d681SAndroid Build Coastguard Worker; int mnums; 8*9880d681SAndroid Build Coastguard Worker; int mrows; 9*9880d681SAndroid Build Coastguard Worker; int mcols; 10*9880d681SAndroid Build Coastguard Worker; int mdeps; 11*9880d681SAndroid Build Coastguard Worker; }; 12*9880d681SAndroid Build Coastguard Worker; 13*9880d681SAndroid Build Coastguard Worker; typedef struct Mat Matrix; 14*9880d681SAndroid Build Coastguard Worker; 15*9880d681SAndroid Build Coastguard Worker; void jacobi(int nn, Matrix* a, Matrix* p) 16*9880d681SAndroid Build Coastguard Worker; { 17*9880d681SAndroid Build Coastguard Worker; long i, j, k, max,jmax,kmax; 18*9880d681SAndroid Build Coastguard Worker; 19*9880d681SAndroid Build Coastguard Worker; p_rows_sub = p->mrows - 1; 20*9880d681SAndroid Build Coastguard Worker; p_cols_sub = p->mcols - 1; 21*9880d681SAndroid Build Coastguard Worker; p_deps_sub = p->mdeps - 1; 22*9880d681SAndroid Build Coastguard Worker; 23*9880d681SAndroid Build Coastguard Worker; for(i = 1; i < p_rows_sub; i++) 24*9880d681SAndroid Build Coastguard Worker; for(j = 1; j < p_cols_sub; j++) 25*9880d681SAndroid Build Coastguard Worker; for(k = 1; k < p_deps_sub; k++) 26*9880d681SAndroid Build Coastguard Worker; MR(a,0,i,j,k) = i + j + k; 27*9880d681SAndroid Build Coastguard Worker; } 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker; 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*9880d681SAndroid Build Coastguard Worker; CHECK: Base offset: %a.base 31*9880d681SAndroid Build Coastguard Worker; CHECK: ArrayDecl[UnknownSize][(sext i32 %a.cols to i64)][(sext i32 %a.deps to i64)] with elements of 4 bytes. 32*9880d681SAndroid Build Coastguard Worker; CHECK: ArrayRef[{1,+,1}<nuw><nsw><%for.i>][{1,+,1}<nuw><nsw><%for.j>][{1,+,1}<nuw><nsw><%for.k>] 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker%struct.Mat = type { float*, i32, i32, i32, i32 } 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Workerdefine void @jacobi(i32 %nn, %struct.Mat* nocapture %a, %struct.Mat* nocapture %p) nounwind uwtable { 37*9880d681SAndroid Build Coastguard Workerentry: 38*9880d681SAndroid Build Coastguard Worker %p.rows.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %p, i64 0, i32 2 39*9880d681SAndroid Build Coastguard Worker %p.rows = load i32, i32* %p.rows.ptr 40*9880d681SAndroid Build Coastguard Worker %p.rows.sub = add i32 %p.rows, -1 41*9880d681SAndroid Build Coastguard Worker %p.rows.sext = sext i32 %p.rows.sub to i64 42*9880d681SAndroid Build Coastguard Worker %p.cols.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %p, i64 0, i32 3 43*9880d681SAndroid Build Coastguard Worker %p.cols = load i32, i32* %p.cols.ptr 44*9880d681SAndroid Build Coastguard Worker %p.cols.sub = add i32 %p.cols, -1 45*9880d681SAndroid Build Coastguard Worker %p.cols.sext = sext i32 %p.cols.sub to i64 46*9880d681SAndroid Build Coastguard Worker %p.deps.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %p, i64 0, i32 4 47*9880d681SAndroid Build Coastguard Worker %p.deps = load i32, i32* %p.deps.ptr 48*9880d681SAndroid Build Coastguard Worker %p.deps.sub = add i32 %p.deps, -1 49*9880d681SAndroid Build Coastguard Worker %p.deps.sext = sext i32 %p.deps.sub to i64 50*9880d681SAndroid Build Coastguard Worker %a.cols.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %a, i64 0, i32 3 51*9880d681SAndroid Build Coastguard Worker %a.cols = load i32, i32* %a.cols.ptr 52*9880d681SAndroid Build Coastguard Worker %a.deps.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %a, i64 0, i32 4 53*9880d681SAndroid Build Coastguard Worker %a.deps = load i32, i32* %a.deps.ptr 54*9880d681SAndroid Build Coastguard Worker %a.base.ptr = getelementptr inbounds %struct.Mat, %struct.Mat* %a, i64 0, i32 0 55*9880d681SAndroid Build Coastguard Worker %a.base = load float*, float** %a.base.ptr, align 8 56*9880d681SAndroid Build Coastguard Worker br label %for.i 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Workerfor.i: ; preds = %for.i.inc, %entry 59*9880d681SAndroid Build Coastguard Worker %i = phi i64 [ %i.inc, %for.i.inc ], [ 1, %entry ] 60*9880d681SAndroid Build Coastguard Worker br label %for.j 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Workerfor.j: ; preds = %for.j.inc, %for.i 63*9880d681SAndroid Build Coastguard Worker %j = phi i64 [ %j.inc, %for.j.inc ], [ 1, %for.i ] 64*9880d681SAndroid Build Coastguard Worker %a.cols.sext = sext i32 %a.cols to i64 65*9880d681SAndroid Build Coastguard Worker %a.deps.sext = sext i32 %a.deps to i64 66*9880d681SAndroid Build Coastguard Worker br label %for.k 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Workerfor.k: ; preds = %for.k, %for.j 69*9880d681SAndroid Build Coastguard Worker %k = phi i64 [ 1, %for.j ], [ %k.inc, %for.k ] 70*9880d681SAndroid Build Coastguard Worker %tmp1 = mul nsw i64 %a.cols.sext, %i 71*9880d681SAndroid Build Coastguard Worker %tmp2 = add i64 %tmp1, %j 72*9880d681SAndroid Build Coastguard Worker %tmp3 = mul i64 %tmp2, %a.deps.sext 73*9880d681SAndroid Build Coastguard Worker %tmp4 = add nsw i64 %k, %tmp3 74*9880d681SAndroid Build Coastguard Worker %arrayidx = getelementptr inbounds float, float* %a.base, i64 %tmp4 75*9880d681SAndroid Build Coastguard Worker store float 1.000000e+00, float* %arrayidx 76*9880d681SAndroid Build Coastguard Worker %k.inc = add nsw i64 %k, 1 77*9880d681SAndroid Build Coastguard Worker %k.exitcond = icmp eq i64 %k.inc, %p.deps.sext 78*9880d681SAndroid Build Coastguard Worker br i1 %k.exitcond, label %for.j.inc, label %for.k 79*9880d681SAndroid Build Coastguard Worker 80*9880d681SAndroid Build Coastguard Workerfor.j.inc: ; preds = %for.k 81*9880d681SAndroid Build Coastguard Worker %j.inc = add nsw i64 %j, 1 82*9880d681SAndroid Build Coastguard Worker %j.exitcond = icmp eq i64 %j.inc, %p.cols.sext 83*9880d681SAndroid Build Coastguard Worker br i1 %j.exitcond, label %for.i.inc, label %for.j 84*9880d681SAndroid Build Coastguard Worker 85*9880d681SAndroid Build Coastguard Workerfor.i.inc: ; preds = %for.j.inc 86*9880d681SAndroid Build Coastguard Worker %i.inc = add nsw i64 %i, 1 87*9880d681SAndroid Build Coastguard Worker %i.exitcond = icmp eq i64 %i.inc, %p.rows.sext 88*9880d681SAndroid Build Coastguard Worker br i1 %i.exitcond, label %end, label %for.i 89*9880d681SAndroid Build Coastguard Worker 90*9880d681SAndroid Build Coastguard Workerend: ; preds = %for.i.inc 91*9880d681SAndroid Build Coastguard Worker ret void 92*9880d681SAndroid Build Coastguard Worker} 93