1 ; RUN: opt < %s -passes='print<delinearization>' -disable-output 2>&1 | FileCheck %s
3 ; Derived from the following code:
5 ; void foo(long n, long m, long b, double A[n][m]) {
6 ; for (long i = 0; i < n; i++)
7 ; for (long j = 0; j < m; j++)
11 ; AddRec: {{((%m * %b * 8) + %A),+,(2 * %m * 8)}<%for.i>,+,(2 * 8)}<%for.j>
12 ; CHECK: Base offset: %A
13 ; CHECK: ArrayDecl[UnknownSize][%m] with elements of 8 bytes.
14 ; CHECK: ArrayRef[{%b,+,2}<nsw><%for.i>][{0,+,2}<nuw><%for.j>]
17 define void @foo(i64 %n, i64 %m, i64 %b, ptr %A) {
22 %i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ]
23 %outerdim = mul nsw i64 %i, 2
24 %outerdim2 = add nsw i64 %outerdim, %b
25 %tmp = mul nsw i64 %outerdim2, %m
29 %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j ]
30 %prodj = mul i64 %j, 2
31 %vlaarrayidx.sum = add i64 %prodj, %tmp
32 %arrayidx = getelementptr inbounds double, ptr %A, i64 %vlaarrayidx.sum
33 store double 1.0, ptr %arrayidx
34 %j.inc = add nsw i64 %j, 1
35 %j.exitcond = icmp eq i64 %j.inc, %m
36 br i1 %j.exitcond, label %for.i.inc, label %for.j
39 %i.inc = add nsw i64 %i, 1
40 %i.exitcond = icmp eq i64 %i.inc, %n
41 br i1 %i.exitcond, label %end, label %for.i