1; RUN: opt < %s -disable-output "-passes=print<da>" -aa-pipeline=basic-aa 2>&1 \
2; RUN: | FileCheck %s
3; RUN: opt < %s -analyze -enable-new-pm=0 -basic-aa -da | FileCheck %s
4
5; ModuleID = 'SymbolicRDIV.bc'
6target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7target triple = "x86_64-apple-macosx10.6.0"
8
9
10;;  for (long int i = 0; i < n1; i++)
11;;    A[2*i + n1] = i;
12;;  for (long int j = 0; j < n2; j++)
13;;    *B++ = A[3*j + 3*n1];
14
15define void @symbolicrdiv0(i32* %A, i32* %B, i64 %n1, i64 %n2) nounwind uwtable ssp {
16entry:
17  %cmp4 = icmp eq i64 %n1, 0
18  br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader
19
20; CHECK: 'Dependence Analysis' for function 'symbolicrdiv0'
21; CHECK: da analyze - none!
22; CHECK: da analyze - none!
23; CHECK: da analyze - confused!
24; CHECK: da analyze - none!
25; CHECK: da analyze - confused!
26; CHECK: da analyze - none!
27
28for.body.preheader:                               ; preds = %entry
29  br label %for.body
30
31for.cond1.preheader.loopexit:                     ; preds = %for.body
32  br label %for.cond1.preheader
33
34for.cond1.preheader:                              ; preds = %for.cond1.preheader.loopexit, %entry
35  %cmp21 = icmp eq i64 %n2, 0
36  br i1 %cmp21, label %for.end11, label %for.body4.preheader
37
38for.body4.preheader:                              ; preds = %for.cond1.preheader
39  br label %for.body4
40
41for.body:                                         ; preds = %for.body.preheader, %for.body
42  %i.05 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
43  %conv = trunc i64 %i.05 to i32
44  %mul = shl nsw i64 %i.05, 1
45  %add = add i64 %mul, %n1
46  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
47  store i32 %conv, i32* %arrayidx, align 4
48  %inc = add nsw i64 %i.05, 1
49  %exitcond = icmp ne i64 %inc, %n1
50  br i1 %exitcond, label %for.body, label %for.cond1.preheader.loopexit
51
52for.body4:                                        ; preds = %for.body4.preheader, %for.body4
53  %j.03 = phi i64 [ %inc10, %for.body4 ], [ 0, %for.body4.preheader ]
54  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body4 ], [ %B, %for.body4.preheader ]
55  %mul56 = add i64 %j.03, %n1
56  %add7 = mul i64 %mul56, 3
57  %arrayidx8 = getelementptr inbounds i32, i32* %A, i64 %add7
58  %0 = load i32, i32* %arrayidx8, align 4
59  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
60  store i32 %0, i32* %B.addr.02, align 4
61  %inc10 = add nsw i64 %j.03, 1
62  %exitcond7 = icmp ne i64 %inc10, %n2
63  br i1 %exitcond7, label %for.body4, label %for.end11.loopexit
64
65for.end11.loopexit:                               ; preds = %for.body4
66  br label %for.end11
67
68for.end11:                                        ; preds = %for.end11.loopexit, %for.cond1.preheader
69  ret void
70}
71
72
73;;  for (long int i = 0; i < n1; i++)
74;;    A[2*i + 5*n2] = i;
75;;  for (long int j = 0; j < n2; j++)
76;;    *B++ = A[3*j + 2*n2];
77
78define void @symbolicrdiv1(i32* %A, i32* %B, i64 %n1, i64 %n2) nounwind uwtable ssp {
79entry:
80  %cmp4 = icmp eq i64 %n1, 0
81  br i1 %cmp4, label %for.cond2.preheader, label %for.body.preheader
82
83; CHECK: 'Dependence Analysis' for function 'symbolicrdiv1'
84; CHECK: da analyze - none!
85; CHECK: da analyze - none!
86; CHECK: da analyze - confused!
87; CHECK: da analyze - none!
88; CHECK: da analyze - confused!
89; CHECK: da analyze - none!
90
91for.body.preheader:                               ; preds = %entry
92  br label %for.body
93
94for.cond2.preheader.loopexit:                     ; preds = %for.body
95  br label %for.cond2.preheader
96
97for.cond2.preheader:                              ; preds = %for.cond2.preheader.loopexit, %entry
98  %cmp31 = icmp eq i64 %n2, 0
99  br i1 %cmp31, label %for.end12, label %for.body5.preheader
100
101for.body5.preheader:                              ; preds = %for.cond2.preheader
102  br label %for.body5
103
104for.body:                                         ; preds = %for.body.preheader, %for.body
105  %i.05 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
106  %conv = trunc i64 %i.05 to i32
107  %mul = shl nsw i64 %i.05, 1
108  %mul1 = mul i64 %n2, 5
109  %add = add i64 %mul, %mul1
110  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
111  store i32 %conv, i32* %arrayidx, align 4
112  %inc = add nsw i64 %i.05, 1
113  %exitcond = icmp ne i64 %inc, %n1
114  br i1 %exitcond, label %for.body, label %for.cond2.preheader.loopexit
115
116for.body5:                                        ; preds = %for.body5.preheader, %for.body5
117  %j.03 = phi i64 [ %inc11, %for.body5 ], [ 0, %for.body5.preheader ]
118  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body5 ], [ %B, %for.body5.preheader ]
119  %mul6 = mul nsw i64 %j.03, 3
120  %mul7 = shl i64 %n2, 1
121  %add8 = add i64 %mul6, %mul7
122  %arrayidx9 = getelementptr inbounds i32, i32* %A, i64 %add8
123  %0 = load i32, i32* %arrayidx9, align 4
124  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
125  store i32 %0, i32* %B.addr.02, align 4
126  %inc11 = add nsw i64 %j.03, 1
127  %exitcond6 = icmp ne i64 %inc11, %n2
128  br i1 %exitcond6, label %for.body5, label %for.end12.loopexit
129
130for.end12.loopexit:                               ; preds = %for.body5
131  br label %for.end12
132
133for.end12:                                        ; preds = %for.end12.loopexit, %for.cond2.preheader
134  ret void
135}
136
137
138;;  for (long int i = 0; i < n1; i++)
139;;    A[2*i - n2] = i;
140;;  for (long int j = 0; j < n2; j++)
141;;    *B++ = A[-j + 2*n1];
142
143define void @symbolicrdiv2(i32* %A, i32* %B, i64 %n1, i64 %n2) nounwind uwtable ssp {
144entry:
145  %cmp4 = icmp eq i64 %n1, 0
146  br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader
147
148; CHECK: 'Dependence Analysis' for function 'symbolicrdiv2'
149; CHECK: da analyze - none!
150; CHECK: da analyze - none!
151; CHECK: da analyze - confused!
152; CHECK: da analyze - none!
153; CHECK: da analyze - confused!
154; CHECK: da analyze - none!
155
156for.body.preheader:                               ; preds = %entry
157  br label %for.body
158
159for.cond1.preheader.loopexit:                     ; preds = %for.body
160  br label %for.cond1.preheader
161
162for.cond1.preheader:                              ; preds = %for.cond1.preheader.loopexit, %entry
163  %cmp21 = icmp eq i64 %n2, 0
164  br i1 %cmp21, label %for.end10, label %for.body4.preheader
165
166for.body4.preheader:                              ; preds = %for.cond1.preheader
167  br label %for.body4
168
169for.body:                                         ; preds = %for.body.preheader, %for.body
170  %i.05 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
171  %conv = trunc i64 %i.05 to i32
172  %mul = shl nsw i64 %i.05, 1
173  %sub = sub i64 %mul, %n2
174  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %sub
175  store i32 %conv, i32* %arrayidx, align 4
176  %inc = add nsw i64 %i.05, 1
177  %exitcond = icmp ne i64 %inc, %n1
178  br i1 %exitcond, label %for.body, label %for.cond1.preheader.loopexit
179
180for.body4:                                        ; preds = %for.body4.preheader, %for.body4
181  %j.03 = phi i64 [ %inc9, %for.body4 ], [ 0, %for.body4.preheader ]
182  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body4 ], [ %B, %for.body4.preheader ]
183  %mul6 = shl i64 %n1, 1
184  %add = sub i64 %mul6, %j.03
185  %arrayidx7 = getelementptr inbounds i32, i32* %A, i64 %add
186  %0 = load i32, i32* %arrayidx7, align 4
187  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
188  store i32 %0, i32* %B.addr.02, align 4
189  %inc9 = add nsw i64 %j.03, 1
190  %exitcond6 = icmp ne i64 %inc9, %n2
191  br i1 %exitcond6, label %for.body4, label %for.end10.loopexit
192
193for.end10.loopexit:                               ; preds = %for.body4
194  br label %for.end10
195
196for.end10:                                        ; preds = %for.end10.loopexit, %for.cond1.preheader
197  ret void
198}
199
200
201;;  for (long int i = 0; i < n1; i++)
202;;    A[-i + n2] = i;
203;;  for (long int j = 0; j < n2; j++)
204;;    *B++ = A[j - n1];
205
206define void @symbolicrdiv3(i32* %A, i32* %B, i64 %n1, i64 %n2) nounwind uwtable ssp {
207entry:
208  %cmp4 = icmp eq i64 %n1, 0
209  br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader
210
211; CHECK: 'Dependence Analysis' for function 'symbolicrdiv3'
212; CHECK: da analyze - none!
213; CHECK: da analyze - none!
214; CHECK: da analyze - confused!
215; CHECK: da analyze - none!
216; CHECK: da analyze - confused!
217; CHECK: da analyze - none!
218
219for.body.preheader:                               ; preds = %entry
220  br label %for.body
221
222for.cond1.preheader.loopexit:                     ; preds = %for.body
223  br label %for.cond1.preheader
224
225for.cond1.preheader:                              ; preds = %for.cond1.preheader.loopexit, %entry
226  %cmp21 = icmp eq i64 %n2, 0
227  br i1 %cmp21, label %for.end9, label %for.body4.preheader
228
229for.body4.preheader:                              ; preds = %for.cond1.preheader
230  br label %for.body4
231
232for.body:                                         ; preds = %for.body.preheader, %for.body
233  %i.05 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
234  %conv = trunc i64 %i.05 to i32
235  %add = sub i64 %n2, %i.05
236  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
237  store i32 %conv, i32* %arrayidx, align 4
238  %inc = add nsw i64 %i.05, 1
239  %exitcond = icmp ne i64 %inc, %n1
240  br i1 %exitcond, label %for.body, label %for.cond1.preheader.loopexit
241
242for.body4:                                        ; preds = %for.body4.preheader, %for.body4
243  %j.03 = phi i64 [ %inc8, %for.body4 ], [ 0, %for.body4.preheader ]
244  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body4 ], [ %B, %for.body4.preheader ]
245  %sub5 = sub i64 %j.03, %n1
246  %arrayidx6 = getelementptr inbounds i32, i32* %A, i64 %sub5
247  %0 = load i32, i32* %arrayidx6, align 4
248  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
249  store i32 %0, i32* %B.addr.02, align 4
250  %inc8 = add nsw i64 %j.03, 1
251  %exitcond6 = icmp ne i64 %inc8, %n2
252  br i1 %exitcond6, label %for.body4, label %for.end9.loopexit
253
254for.end9.loopexit:                                ; preds = %for.body4
255  br label %for.end9
256
257for.end9:                                         ; preds = %for.end9.loopexit, %for.cond1.preheader
258  ret void
259}
260
261
262;;  for (long int i = 0; i < n1; i++)
263;;    A[-i + 2*n1] = i;
264;;  for (long int j = 0; j < n2; j++)
265;;    *B++ = A[-j + n1];
266
267define void @symbolicrdiv4(i32* %A, i32* %B, i64 %n1, i64 %n2) nounwind uwtable ssp {
268entry:
269  %cmp4 = icmp eq i64 %n1, 0
270  br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader
271
272; CHECK: 'Dependence Analysis' for function 'symbolicrdiv4'
273; CHECK: da analyze - none!
274; CHECK: da analyze - none!
275; CHECK: da analyze - confused!
276; CHECK: da analyze - none!
277; CHECK: da analyze - confused!
278; CHECK: da analyze - none!
279
280for.body.preheader:                               ; preds = %entry
281  br label %for.body
282
283for.cond1.preheader.loopexit:                     ; preds = %for.body
284  br label %for.cond1.preheader
285
286for.cond1.preheader:                              ; preds = %for.cond1.preheader.loopexit, %entry
287  %cmp21 = icmp eq i64 %n2, 0
288  br i1 %cmp21, label %for.end10, label %for.body4.preheader
289
290for.body4.preheader:                              ; preds = %for.cond1.preheader
291  br label %for.body4
292
293for.body:                                         ; preds = %for.body.preheader, %for.body
294  %i.05 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
295  %conv = trunc i64 %i.05 to i32
296  %mul = shl i64 %n1, 1
297  %add = sub i64 %mul, %i.05
298  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
299  store i32 %conv, i32* %arrayidx, align 4
300  %inc = add nsw i64 %i.05, 1
301  %exitcond = icmp ne i64 %inc, %n1
302  br i1 %exitcond, label %for.body, label %for.cond1.preheader.loopexit
303
304for.body4:                                        ; preds = %for.body4.preheader, %for.body4
305  %j.03 = phi i64 [ %inc9, %for.body4 ], [ 0, %for.body4.preheader ]
306  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body4 ], [ %B, %for.body4.preheader ]
307  %add6 = sub i64 %n1, %j.03
308  %arrayidx7 = getelementptr inbounds i32, i32* %A, i64 %add6
309  %0 = load i32, i32* %arrayidx7, align 4
310  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
311  store i32 %0, i32* %B.addr.02, align 4
312  %inc9 = add nsw i64 %j.03, 1
313  %exitcond6 = icmp ne i64 %inc9, %n2
314  br i1 %exitcond6, label %for.body4, label %for.end10.loopexit
315
316for.end10.loopexit:                               ; preds = %for.body4
317  br label %for.end10
318
319for.end10:                                        ; preds = %for.end10.loopexit, %for.cond1.preheader
320  ret void
321}
322
323
324;;  for (long int i = 0; i < n1; i++)
325;;    A[-i + n2] = i;
326;;  for (long int j = 0; j < n2; j++)
327;;    *B++ = A[-j + 2*n2];
328
329define void @symbolicrdiv5(i32* %A, i32* %B, i64 %n1, i64 %n2) nounwind uwtable ssp {
330entry:
331  %cmp4 = icmp eq i64 %n1, 0
332  br i1 %cmp4, label %for.cond1.preheader, label %for.body.preheader
333
334; CHECK: 'Dependence Analysis' for function 'symbolicrdiv5'
335; CHECK: da analyze - none!
336; CHECK: da analyze - none!
337; CHECK: da analyze - confused!
338; CHECK: da analyze - none!
339; CHECK: da analyze - confused!
340; CHECK: da analyze - none!
341
342for.body.preheader:                               ; preds = %entry
343  br label %for.body
344
345for.cond1.preheader.loopexit:                     ; preds = %for.body
346  br label %for.cond1.preheader
347
348for.cond1.preheader:                              ; preds = %for.cond1.preheader.loopexit, %entry
349  %cmp21 = icmp eq i64 %n2, 0
350  br i1 %cmp21, label %for.end10, label %for.body4.preheader
351
352for.body4.preheader:                              ; preds = %for.cond1.preheader
353  br label %for.body4
354
355for.body:                                         ; preds = %for.body.preheader, %for.body
356  %i.05 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
357  %conv = trunc i64 %i.05 to i32
358  %add = sub i64 %n2, %i.05
359  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
360  store i32 %conv, i32* %arrayidx, align 4
361  %inc = add nsw i64 %i.05, 1
362  %exitcond = icmp ne i64 %inc, %n1
363  br i1 %exitcond, label %for.body, label %for.cond1.preheader.loopexit
364
365for.body4:                                        ; preds = %for.body4.preheader, %for.body4
366  %j.03 = phi i64 [ %inc9, %for.body4 ], [ 0, %for.body4.preheader ]
367  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body4 ], [ %B, %for.body4.preheader ]
368  %mul = shl i64 %n2, 1
369  %add6 = sub i64 %mul, %j.03
370  %arrayidx7 = getelementptr inbounds i32, i32* %A, i64 %add6
371  %0 = load i32, i32* %arrayidx7, align 4
372  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
373  store i32 %0, i32* %B.addr.02, align 4
374  %inc9 = add nsw i64 %j.03, 1
375  %exitcond6 = icmp ne i64 %inc9, %n2
376  br i1 %exitcond6, label %for.body4, label %for.end10.loopexit
377
378for.end10.loopexit:                               ; preds = %for.body4
379  br label %for.end10
380
381for.end10:                                        ; preds = %for.end10.loopexit, %for.cond1.preheader
382  ret void
383}
384
385
386;;  for (long int i = 0; i < n1; i++)
387;;    for (long int j = 0; j < n2; j++) {
388;;      A[j -i + n2] = i;
389;;      *B++ = A[2*n2];
390
391define void @symbolicrdiv6(i32* %A, i32* %B, i64 %n1, i64 %n2) nounwind uwtable ssp {
392entry:
393  %cmp4 = icmp eq i64 %n1, 0
394  br i1 %cmp4, label %for.end7, label %for.cond1.preheader.preheader
395
396; CHECK: 'Dependence Analysis' for function 'symbolicrdiv6'
397; CHECK: da analyze - output [* *]!
398; CHECK: da analyze - none!
399; CHECK: da analyze - confused!
400; CHECK: da analyze - consistent input [S S]!
401; CHECK: da analyze - confused!
402; CHECK: da analyze - output [* *]!
403
404for.cond1.preheader.preheader:                    ; preds = %entry
405  br label %for.cond1.preheader
406
407for.cond1.preheader:                              ; preds = %for.cond1.preheader.preheader, %for.inc5
408  %B.addr.06 = phi i32* [ %B.addr.1.lcssa, %for.inc5 ], [ %B, %for.cond1.preheader.preheader ]
409  %i.05 = phi i64 [ %inc6, %for.inc5 ], [ 0, %for.cond1.preheader.preheader ]
410  %cmp21 = icmp eq i64 %n2, 0
411  br i1 %cmp21, label %for.inc5, label %for.body3.preheader
412
413for.body3.preheader:                              ; preds = %for.cond1.preheader
414  br label %for.body3
415
416for.body3:                                        ; preds = %for.body3.preheader, %for.body3
417  %j.03 = phi i64 [ %inc, %for.body3 ], [ 0, %for.body3.preheader ]
418  %B.addr.12 = phi i32* [ %incdec.ptr, %for.body3 ], [ %B.addr.06, %for.body3.preheader ]
419  %conv = trunc i64 %i.05 to i32
420  %sub = sub nsw i64 %j.03, %i.05
421  %add = add i64 %sub, %n2
422  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
423  store i32 %conv, i32* %arrayidx, align 4
424  %mul = shl i64 %n2, 1
425  %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %mul
426  %0 = load i32, i32* %arrayidx4, align 4
427  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.12, i64 1
428  store i32 %0, i32* %B.addr.12, align 4
429  %inc = add nsw i64 %j.03, 1
430  %exitcond = icmp ne i64 %inc, %n2
431  br i1 %exitcond, label %for.body3, label %for.inc5.loopexit
432
433for.inc5.loopexit:                                ; preds = %for.body3
434  %scevgep = getelementptr i32, i32* %B.addr.06, i64 %n2
435  br label %for.inc5
436
437for.inc5:                                         ; preds = %for.inc5.loopexit, %for.cond1.preheader
438  %B.addr.1.lcssa = phi i32* [ %B.addr.06, %for.cond1.preheader ], [ %scevgep, %for.inc5.loopexit ]
439  %inc6 = add nsw i64 %i.05, 1
440  %exitcond7 = icmp ne i64 %inc6, %n1
441  br i1 %exitcond7, label %for.cond1.preheader, label %for.end7.loopexit
442
443for.end7.loopexit:                                ; preds = %for.inc5
444  br label %for.end7
445
446for.end7:                                         ; preds = %for.end7.loopexit, %entry
447  ret void
448}
449