• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -analyze -enable-new-pm=0 -delinearize | FileCheck %s
2; RUN: opt < %s -passes='print<delinearization>' -disable-output 2>&1 | FileCheck %s
3
4; Derived from the following code:
5;
6; void foo(long n, long m, double A[n][m]) {
7;   for (long i = 0; i < n; i++)
8;     for (long j = 0; j < m; j++)
9;       A[i][j] = 1.0;
10; }
11
12; Inst:  %val = load double, double* %arrayidx
13; In Loop with Header: for.j
14; AddRec: {{0,+,(%m * 8)}<%for.i>,+,8}<%for.j>
15; Base offset: %A
16; ArrayDecl[UnknownSize][%m] with elements of 8 bytes.
17; ArrayRef[{0,+,1}<nuw><nsw><%for.i>][{0,+,1}<nuw><nsw><%for.j>]
18
19; Inst:  store double %val, double* %arrayidx
20; In Loop with Header: for.j
21; AddRec: {{%A,+,(8 * %m)}<%for.i>,+,8}<%for.j>
22; CHECK: Base offset: %A
23; CHECK: ArrayDecl[UnknownSize][%m] with elements of 8 bytes.
24; CHECK: ArrayRef[{0,+,1}<nuw><nsw><%for.i>][{0,+,1}<nuw><nsw><%for.j>]
25
26define void @foo(i64 %n, i64 %m, double* %A) {
27entry:
28  br label %for.i
29
30for.i:
31  %i = phi i64 [ 0, %entry ], [ %i.inc, %for.i.inc ]
32  %tmp = mul nsw i64 %i, %m
33  br label %for.j
34
35for.j:
36  %j = phi i64 [ 0, %for.i ], [ %j.inc, %for.j ]
37  %vlaarrayidx.sum = add i64 %j, %tmp
38  %arrayidx = getelementptr inbounds double, double* %A, i64 %vlaarrayidx.sum
39  %val = load double, double* %arrayidx
40  store double %val, double* %arrayidx
41  %j.inc = add nsw i64 %j, 1
42  %j.exitcond = icmp eq i64 %j.inc, %m
43  br i1 %j.exitcond, label %for.i.inc, label %for.j
44
45for.i.inc:
46  %i.inc = add nsw i64 %i, 1
47  %i.exitcond = icmp eq i64 %i.inc, %n
48  br i1 %i.exitcond, label %end, label %for.i
49
50end:
51  ret void
52}
53