1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
2;
3;    #define N 400
4;
5;    void first_higher_dimensional(float A[][N]) {
6;      for (long i = 0; i < N; i++)
7;        for (long j = 0; j < N; j++)
8;          A[i][j] += i + j;
9;
10;      A[0][0] += A[100][100];
11;
12;      for (long i = 0; i < N; i++)
13;        for (long j = 0; j < N; j++)
14;          A[i][j] += i + j;
15;    }
16
17;    void first_lower_dimensional(float A[][N], float B[][N]) {
18;      for (long i = 0; i < N; i++)
19;        for (long j = 0; j < N; j++)
20;          B[i][j] += i + j;
21;
22;      A[0][0] += B[100][100];
23;
24;      for (long i = 0; i < N; i++)
25;        for (long j = 0; j < N; j++)
26;          A[i][j] += i + j;
27;    }
28
29; CHECK:      Statements {
30; CHECK-NEXT:     Stmt_bb7
31; CHECK-NEXT:         Domain :=
32; CHECK-NEXT:             { Stmt_bb7[i0, i1] : 0 <= i0 <= 399 and 0 <= i1 <= 399 };
33; CHECK-NEXT:         Schedule :=
34; CHECK-NEXT:             { Stmt_bb7[i0, i1] -> [0, i0, i1] };
35; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
36; CHECK-NEXT:             { Stmt_bb7[i0, i1] -> MemRef_A[i0, i1] };
37; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
38; CHECK-NEXT:             { Stmt_bb7[i0, i1] -> MemRef_A[i0, i1] };
39; CHECK-NEXT:     Stmt_bb17
40; CHECK-NEXT:         Domain :=
41; CHECK-NEXT:             { Stmt_bb17[] };
42; CHECK-NEXT:         Schedule :=
43; CHECK-NEXT:             { Stmt_bb17[] -> [1, 0, 0] };
44; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
45; CHECK-NEXT:             { Stmt_bb17[] -> MemRef_A[100, 100] };
46; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
47; CHECK-NEXT:             { Stmt_bb17[] -> MemRef_A[0, 0] };
48; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
49; CHECK-NEXT:             { Stmt_bb17[] -> MemRef_A[0, 0] };
50; CHECK-NEXT:     Stmt_bb26
51; CHECK-NEXT:         Domain :=
52; CHECK-NEXT:             { Stmt_bb26[i0, i1] : 0 <= i0 <= 399 and 0 <= i1 <= 399 };
53; CHECK-NEXT:         Schedule :=
54; CHECK-NEXT:             { Stmt_bb26[i0, i1] -> [2, i0, i1] };
55; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
56; CHECK-NEXT:             { Stmt_bb26[i0, i1] -> MemRef_A[i0, i1] };
57; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
58; CHECK-NEXT:             { Stmt_bb26[i0, i1] -> MemRef_A[i0, i1] };
59; CHECK-NEXT: }
60;
61; CHECK:      Statements {
62; CHECK-NEXT:     Stmt_bb7
63; CHECK-NEXT:         Domain :=
64; CHECK-NEXT:             { Stmt_bb7[i0, i1] : 0 <= i0 <= 399 and 0 <= i1 <= 399 };
65; CHECK-NEXT:         Schedule :=
66; CHECK-NEXT:             { Stmt_bb7[i0, i1] -> [0, i0, i1] };
67; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
68; CHECK-NEXT:             { Stmt_bb7[i0, i1] -> MemRef_B[i0, i1] };
69; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
70; CHECK-NEXT:             { Stmt_bb7[i0, i1] -> MemRef_B[i0, i1] };
71; CHECK-NEXT:     Stmt_bb17
72; CHECK-NEXT:         Domain :=
73; CHECK-NEXT:             { Stmt_bb17[] };
74; CHECK-NEXT:         Schedule :=
75; CHECK-NEXT:             { Stmt_bb17[] -> [1, 0, 0] };
76; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
77; CHECK-NEXT:             { Stmt_bb17[] -> MemRef_B[100, 100] };
78; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
79; CHECK-NEXT:             { Stmt_bb17[] -> MemRef_A[0, 0] };
80; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
81; CHECK-NEXT:             { Stmt_bb17[] -> MemRef_A[0, 0] };
82; CHECK-NEXT:     Stmt_bb26
83; CHECK-NEXT:         Domain :=
84; CHECK-NEXT:             { Stmt_bb26[i0, i1] : 0 <= i0 <= 399 and 0 <= i1 <= 399 };
85; CHECK-NEXT:         Schedule :=
86; CHECK-NEXT:             { Stmt_bb26[i0, i1] -> [2, i0, i1] };
87; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
88; CHECK-NEXT:             { Stmt_bb26[i0, i1] -> MemRef_A[i0, i1] };
89; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
90; CHECK-NEXT:             { Stmt_bb26[i0, i1] -> MemRef_A[i0, i1] };
91; CHECK-NEXT: }
92
93target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
94
95define void @first_higher_dimensional([400 x float]* %A) {
96bb:
97  br label %bb4
98
99bb4:                                              ; preds = %bb15, %bb
100  %i.0 = phi i64 [ 0, %bb ], [ %tmp16, %bb15 ]
101  %exitcond3 = icmp ne i64 %i.0, 400
102  br i1 %exitcond3, label %bb5, label %bb17
103
104bb5:                                              ; preds = %bb4
105  br label %bb6
106
107bb6:                                              ; preds = %bb12, %bb5
108  %j.0 = phi i64 [ 0, %bb5 ], [ %tmp13, %bb12 ]
109  %exitcond2 = icmp ne i64 %j.0, 400
110  br i1 %exitcond2, label %bb7, label %bb14
111
112bb7:                                              ; preds = %bb6
113  %tmp = add nuw nsw i64 %i.0, %j.0
114  %tmp8 = sitofp i64 %tmp to float
115  %tmp9 = getelementptr inbounds [400 x float], [400 x float]* %A, i64 %i.0, i64 %j.0
116  %tmp10 = load float, float* %tmp9, align 4
117  %tmp11 = fadd float %tmp10, %tmp8
118  store float %tmp11, float* %tmp9, align 4
119  br label %bb12
120
121bb12:                                             ; preds = %bb7
122  %tmp13 = add nuw nsw i64 %j.0, 1
123  br label %bb6
124
125bb14:                                             ; preds = %bb6
126  br label %bb15
127
128bb15:                                             ; preds = %bb14
129  %tmp16 = add nuw nsw i64 %i.0, 1
130  br label %bb4
131
132bb17:                                             ; preds = %bb4
133  %tmp18 = getelementptr inbounds [400 x float], [400 x float]* %A, i64 100, i64 100
134  %tmp19 = load float, float* %tmp18, align 4
135  %tmp20 = getelementptr inbounds [400 x float], [400 x float]* %A, i64 0, i64 0
136  %tmp21 = load float, float* %tmp20, align 4
137  %tmp22 = fadd float %tmp21, %tmp19
138  store float %tmp22, float* %tmp20, align 4
139  br label %bb23
140
141bb23:                                             ; preds = %bb35, %bb17
142  %i1.0 = phi i64 [ 0, %bb17 ], [ %tmp36, %bb35 ]
143  %exitcond1 = icmp ne i64 %i1.0, 400
144  br i1 %exitcond1, label %bb24, label %bb37
145
146bb24:                                             ; preds = %bb23
147  br label %bb25
148
149bb25:                                             ; preds = %bb32, %bb24
150  %j2.0 = phi i64 [ 0, %bb24 ], [ %tmp33, %bb32 ]
151  %exitcond = icmp ne i64 %j2.0, 400
152  br i1 %exitcond, label %bb26, label %bb34
153
154bb26:                                             ; preds = %bb25
155  %tmp27 = add nuw nsw i64 %i1.0, %j2.0
156  %tmp28 = sitofp i64 %tmp27 to float
157  %tmp29 = getelementptr inbounds [400 x float], [400 x float]* %A, i64 %i1.0, i64 %j2.0
158  %tmp30 = load float, float* %tmp29, align 4
159  %tmp31 = fadd float %tmp30, %tmp28
160  store float %tmp31, float* %tmp29, align 4
161  br label %bb32
162
163bb32:                                             ; preds = %bb26
164  %tmp33 = add nuw nsw i64 %j2.0, 1
165  br label %bb25
166
167bb34:                                             ; preds = %bb25
168  br label %bb35
169
170bb35:                                             ; preds = %bb34
171  %tmp36 = add nuw nsw i64 %i1.0, 1
172  br label %bb23
173
174bb37:                                             ; preds = %bb23
175  ret void
176}
177
178define void @first_lower_dimensional([400 x float]* %A, [400 x float]* %B) {
179bb:
180  br label %bb4
181
182bb4:                                              ; preds = %bb15, %bb
183  %i.0 = phi i64 [ 0, %bb ], [ %tmp16, %bb15 ]
184  %exitcond3 = icmp ne i64 %i.0, 400
185  br i1 %exitcond3, label %bb5, label %bb17
186
187bb5:                                              ; preds = %bb4
188  br label %bb6
189
190bb6:                                              ; preds = %bb12, %bb5
191  %j.0 = phi i64 [ 0, %bb5 ], [ %tmp13, %bb12 ]
192  %exitcond2 = icmp ne i64 %j.0, 400
193  br i1 %exitcond2, label %bb7, label %bb14
194
195bb7:                                              ; preds = %bb6
196  %tmp = add nuw nsw i64 %i.0, %j.0
197  %tmp8 = sitofp i64 %tmp to float
198  %tmp9 = getelementptr inbounds [400 x float], [400 x float]* %B, i64 %i.0, i64 %j.0
199  %tmp10 = load float, float* %tmp9, align 4
200  %tmp11 = fadd float %tmp10, %tmp8
201  store float %tmp11, float* %tmp9, align 4
202  br label %bb12
203
204bb12:                                             ; preds = %bb7
205  %tmp13 = add nuw nsw i64 %j.0, 1
206  br label %bb6
207
208bb14:                                             ; preds = %bb6
209  br label %bb15
210
211bb15:                                             ; preds = %bb14
212  %tmp16 = add nuw nsw i64 %i.0, 1
213  br label %bb4
214
215bb17:                                             ; preds = %bb4
216  %tmp18 = getelementptr inbounds [400 x float], [400 x float]* %B, i64 100, i64 100
217  %tmp19 = load float, float* %tmp18, align 4
218  %tmp20 = getelementptr inbounds [400 x float], [400 x float]* %A, i64 0, i64 0
219  %tmp21 = load float, float* %tmp20, align 4
220  %tmp22 = fadd float %tmp21, %tmp19
221  store float %tmp22, float* %tmp20, align 4
222  br label %bb23
223
224bb23:                                             ; preds = %bb35, %bb17
225  %i1.0 = phi i64 [ 0, %bb17 ], [ %tmp36, %bb35 ]
226  %exitcond1 = icmp ne i64 %i1.0, 400
227  br i1 %exitcond1, label %bb24, label %bb37
228
229bb24:                                             ; preds = %bb23
230  br label %bb25
231
232bb25:                                             ; preds = %bb32, %bb24
233  %j2.0 = phi i64 [ 0, %bb24 ], [ %tmp33, %bb32 ]
234  %exitcond = icmp ne i64 %j2.0, 400
235  br i1 %exitcond, label %bb26, label %bb34
236
237bb26:                                             ; preds = %bb25
238  %tmp27 = add nuw nsw i64 %i1.0, %j2.0
239  %tmp28 = sitofp i64 %tmp27 to float
240  %tmp29 = getelementptr inbounds [400 x float], [400 x float]* %A, i64 %i1.0, i64 %j2.0
241  %tmp30 = load float, float* %tmp29, align 4
242  %tmp31 = fadd float %tmp30, %tmp28
243  store float %tmp31, float* %tmp29, align 4
244  br label %bb32
245
246bb32:                                             ; preds = %bb26
247  %tmp33 = add nuw nsw i64 %j2.0, 1
248  br label %bb25
249
250bb34:                                             ; preds = %bb25
251  br label %bb35
252
253bb35:                                             ; preds = %bb34
254  %tmp36 = add nuw nsw i64 %i1.0, 1
255  br label %bb23
256
257bb37:                                             ; preds = %bb23
258  ret void
259}
260