• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -analyze -delinearize | FileCheck %s
2
3; Derived from the following code:
4;
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++)
8;       A[2i+b][2j] = 1.0;
9; }
10
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}<%for.i>][{0,+,2}<%for.j>]
15
16
17define void @foo(i64 %n, i64 %m, i64 %b, double* %A) {
18entry:
19  br label %for.i
20
21for.i:
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
26  br label %for.j
27
28for.j:
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, double* %A, i64 %vlaarrayidx.sum
33  store double 1.0, double* %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
37
38for.i.inc:
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
42
43end:
44  ret void
45}
46