1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-scops -analyze < %s | FileCheck %s
2
3; void foo(long n, long m, long o, double A[n][m][o]) {
4;   for (long i = 0; i < n-3; i++)
5;     for (long j = 4; j < m; j++)
6;       for (long k = 0; k < o-7; k++) {
7;         A[i+3][j-4][k+7] = 1.0;
8;         A[i][0][k] = 2.0;
9;       }
10; }
11
12
13; CHECK: Arrays {
14; CHECK:     double MemRef_A[*][%m][%o]; // Element size 8
15; CHECK: }
16
17; CHECK: [m, o, n] -> { Stmt_for_body6[i0, i1, i2] -> MemRef_A[3 + i0, i1, 7 + i2] };
18; CHECK: [m, o, n] -> { Stmt_for_body6[i0, i1, i2] -> MemRef_A[i0, 0, i2] };
19
20target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
21
22; Function Attrs: nounwind uwtable
23define void @foo(i64 %n, i64 %m, i64 %o, double* nocapture %A) {
24entry:
25  %cmp35 = icmp sgt i64 %n, 0
26  br i1 %cmp35, label %for.cond1.preheader.lr.ph, label %for.end18
27
28for.cond1.preheader.lr.ph:                        ; preds = %entry
29  %cmp233 = icmp sgt i64 %m, 0
30  %cmp531 = icmp sgt i64 %o, 0
31  %0 = mul nuw i64 %o, %m
32  br label %for.cond1.preheader
33
34for.cond1.preheader:                              ; preds = %for.inc16, %for.cond1.preheader.lr.ph
35  %i.036 = phi i64 [ 0, %for.cond1.preheader.lr.ph ], [ %inc17, %for.inc16 ]
36  br i1 %cmp233, label %for.cond4.preheader.lr.ph, label %for.inc16
37
38for.cond4.preheader.lr.ph:                        ; preds = %for.cond1.preheader
39  %add7 = add nsw i64 %i.036, 3
40  %1 = mul nsw i64 %add7, %0
41  %add = add i64 %1, 7
42  %2 = mul nsw i64 %i.036, %0
43  br label %for.cond4.preheader
44
45for.cond4.preheader:                              ; preds = %for.inc13, %for.cond4.preheader.lr.ph
46  %j.034 = phi i64 [ 4, %for.cond4.preheader.lr.ph ], [ %inc14, %for.inc13 ]
47  br i1 %cmp531, label %for.body6.lr.ph, label %for.inc13
48
49for.body6.lr.ph:                                  ; preds = %for.cond4.preheader
50  %sub = add nsw i64 %j.034, -4
51  %3 = mul nsw i64 %sub, %o
52  %arrayidx.sum = add i64 %add, %3
53  br label %for.body6
54
55for.body6:                                        ; preds = %for.body6, %for.body6.lr.ph
56  %k.032 = phi i64 [ 0, %for.body6.lr.ph ], [ %inc, %for.body6 ]
57  %arrayidx8.sum = add i64 %arrayidx.sum, %k.032
58  %arrayidx9 = getelementptr inbounds double, double* %A, i64 %arrayidx8.sum
59  store double 1.000000e+00, double* %arrayidx9, align 8
60  %arrayidx10.sum = add i64 %k.032, %2
61  %arrayidx12 = getelementptr inbounds double, double* %A, i64 %arrayidx10.sum
62  store double 2.000000e+00, double* %arrayidx12, align 8
63  %inc = add nsw i64 %k.032, 1
64  %osub = sub nsw i64 %o, 7
65  %exitcond = icmp eq i64 %inc, %osub
66  br i1 %exitcond, label %for.inc13, label %for.body6
67
68for.inc13:                                        ; preds = %for.body6, %for.cond4.preheader
69  %inc14 = add nsw i64 %j.034, 1
70  %exitcond37 = icmp eq i64 %inc14, %m
71  br i1 %exitcond37, label %for.inc16, label %for.cond4.preheader
72
73for.inc16:                                        ; preds = %for.inc13, %for.cond1.preheader
74  %inc17 = add nsw i64 %i.036, 1
75  %nsub = sub nsw i64 %n, 3
76  %exitcond38 = icmp eq i64 %inc17, %nsub
77  br i1 %exitcond38, label %for.end18, label %for.cond1.preheader
78
79for.end18:                                        ; preds = %for.inc16, %entry
80  ret void
81}
82