1 ; RUN: opt < %s -disable-output "-passes=print<da>" -aa-pipeline=basic-aa 2>&1 \
3 ; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
5 target 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"
6 target triple = "x86_64-apple-macosx10.6.0"
9 ;; for (int i = 0; i < n; i++) {
13 define void @strong0(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
15 %cmp1 = icmp sgt i64 %n, 0
16 br i1 %cmp1, label %for.body.preheader, label %for.end
18 ; CHECK: da analyze - none!
19 ; CHECK: da analyze - consistent flow [2]!
20 ; CHECK: da analyze - confused!
21 ; CHECK: da analyze - none!
22 ; CHECK: da analyze - confused!
23 ; CHECK: da analyze - none!
25 for.body.preheader: ; preds = %entry
28 for.body: ; preds = %for.body.preheader, %for.body
29 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
30 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
31 %0 = add nsw i64 %indvars.iv, 2
32 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %0
33 %1 = trunc i64 %indvars.iv to i32
34 store i32 %1, i32* %arrayidx, align 4
35 %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
36 %2 = load i32, i32* %arrayidx3, align 4
37 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
38 store i32 %2, i32* %B.addr.02, align 4
39 %indvars.iv.next = add i64 %indvars.iv, 1
40 %exitcond = icmp ne i64 %indvars.iv.next, %n
41 br i1 %exitcond, label %for.body, label %for.end.loopexit
43 for.end.loopexit: ; preds = %for.body
46 for.end: ; preds = %for.end.loopexit, %entry
51 ;; for (long int i = 0; i < n; i++) {
55 define void @strong1(i32* %A, i32* %B, i32 %n) nounwind uwtable ssp {
57 %cmp1 = icmp sgt i32 %n, 0
58 br i1 %cmp1, label %for.body.preheader, label %for.end
60 ; CHECK: da analyze - none!
61 ; CHECK: da analyze - consistent flow [2]!
62 ; CHECK: da analyze - confused!
63 ; CHECK: da analyze - none!
64 ; CHECK: da analyze - confused!
65 ; CHECK: da analyze - none!
67 for.body.preheader: ; preds = %entry
68 %0 = sext i32 %n to i64
71 for.body: ; preds = %for.body.preheader, %for.body
72 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
73 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
74 %conv2 = trunc i64 %i.03 to i32
75 %add = add nsw i64 %i.03, 2
76 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
77 store i32 %conv2, i32* %arrayidx, align 4
78 %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %i.03
79 %1 = load i32, i32* %arrayidx3, align 4
80 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
81 store i32 %1, i32* %B.addr.02, align 4
82 %inc = add nsw i64 %i.03, 1
83 %exitcond = icmp ne i64 %inc, %0
84 br i1 %exitcond, label %for.body, label %for.end.loopexit
86 for.end.loopexit: ; preds = %for.body
89 for.end: ; preds = %for.end.loopexit, %entry
94 ;; for (long unsigned i = 0; i < n; i++) {
98 define void @strong2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
100 %cmp1 = icmp eq i64 %n, 0
101 br i1 %cmp1, label %for.end, label %for.body.preheader
103 ; CHECK: da analyze - none!
104 ; CHECK: da analyze - consistent flow [2]!
105 ; CHECK: da analyze - confused!
106 ; CHECK: da analyze - none!
107 ; CHECK: da analyze - confused!
108 ; CHECK: da analyze - none!
110 for.body.preheader: ; preds = %entry
113 for.body: ; preds = %for.body.preheader, %for.body
114 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
115 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
116 %conv = trunc i64 %i.03 to i32
117 %add = add i64 %i.03, 2
118 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
119 store i32 %conv, i32* %arrayidx, align 4
120 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %i.03
121 %0 = load i32, i32* %arrayidx1, align 4
122 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
123 store i32 %0, i32* %B.addr.02, align 4
124 %inc = add i64 %i.03, 1
125 %exitcond = icmp ne i64 %inc, %n
126 br i1 %exitcond, label %for.body, label %for.end.loopexit
128 for.end.loopexit: ; preds = %for.body
131 for.end: ; preds = %for.end.loopexit, %entry
136 ;; for (int i = 0; i < n; i++) {
140 define void @strong3(i32* %A, i32* %B, i32 %n) nounwind uwtable ssp {
142 %cmp1 = icmp sgt i32 %n, 0
143 br i1 %cmp1, label %for.body.preheader, label %for.end
145 ; CHECK: da analyze - none!
146 ; CHECK: da analyze - consistent flow [2]!
147 ; CHECK: da analyze - confused!
148 ; CHECK: da analyze - none!
149 ; CHECK: da analyze - confused!
150 ; CHECK: da analyze - none!
152 for.body.preheader: ; preds = %entry
155 for.body: ; preds = %for.body.preheader, %for.body
156 %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]
157 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
158 %0 = add nsw i64 %indvars.iv, 2
159 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %0
160 %1 = trunc i64 %indvars.iv to i32
161 store i32 %1, i32* %arrayidx, align 4
162 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
163 %2 = load i32, i32* %arrayidx2, align 4
164 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
165 store i32 %2, i32* %B.addr.02, align 4
166 %indvars.iv.next = add i64 %indvars.iv, 1
167 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
168 %exitcond = icmp ne i32 %lftr.wideiv, %n
169 br i1 %exitcond, label %for.body, label %for.end.loopexit
171 for.end.loopexit: ; preds = %for.body
174 for.end: ; preds = %for.end.loopexit, %entry
179 ;; for (long unsigned i = 0; i < 19; i++) {
183 define void @strong4(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
187 ; CHECK: da analyze - none!
188 ; CHECK: da analyze - none!
189 ; CHECK: da analyze - confused!
190 ; CHECK: da analyze - none!
191 ; CHECK: da analyze - confused!
192 ; CHECK: da analyze - none!
194 for.body: ; preds = %entry, %for.body
195 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
196 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
197 %conv = trunc i64 %i.02 to i32
198 %add = add i64 %i.02, 19
199 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
200 store i32 %conv, i32* %arrayidx, align 4
201 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %i.02
202 %0 = load i32, i32* %arrayidx1, align 4
203 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
204 store i32 %0, i32* %B.addr.01, align 4
205 %inc = add i64 %i.02, 1
206 %exitcond = icmp ne i64 %inc, 19
207 br i1 %exitcond, label %for.body, label %for.end
209 for.end: ; preds = %for.body
214 ;; for (long unsigned i = 0; i < 20; i++) {
218 define void @strong5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
222 ; CHECK: da analyze - none!
223 ; CHECK: da analyze - consistent flow [19]!
224 ; CHECK: da analyze - confused!
225 ; CHECK: da analyze - none!
226 ; CHECK: da analyze - confused!
227 ; CHECK: da analyze - none!
229 for.body: ; preds = %entry, %for.body
230 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
231 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
232 %conv = trunc i64 %i.02 to i32
233 %add = add i64 %i.02, 19
234 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
235 store i32 %conv, i32* %arrayidx, align 4
236 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %i.02
237 %0 = load i32, i32* %arrayidx1, align 4
238 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
239 store i32 %0, i32* %B.addr.01, align 4
240 %inc = add i64 %i.02, 1
241 %exitcond = icmp ne i64 %inc, 20
242 br i1 %exitcond, label %for.body, label %for.end
244 for.end: ; preds = %for.body
249 ;; for (long unsigned i = 0; i < 20; i++) {
253 define void @strong6(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
257 ; CHECK: da analyze - none!
258 ; CHECK: da analyze - consistent flow [3]!
259 ; CHECK: da analyze - confused!
260 ; CHECK: da analyze - none!
261 ; CHECK: da analyze - confused!
262 ; CHECK: da analyze - none!
264 for.body: ; preds = %entry, %for.body
265 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
266 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
267 %conv = trunc i64 %i.02 to i32
268 %mul = shl i64 %i.02, 1
269 %add = add i64 %mul, 6
270 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
271 store i32 %conv, i32* %arrayidx, align 4
272 %mul1 = shl i64 %i.02, 1
273 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %mul1
274 %0 = load i32, i32* %arrayidx2, align 4
275 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
276 store i32 %0, i32* %B.addr.01, align 4
277 %inc = add i64 %i.02, 1
278 %exitcond = icmp ne i64 %inc, 20
279 br i1 %exitcond, label %for.body, label %for.end
281 for.end: ; preds = %for.body
286 ;; for (long unsigned i = 0; i < 20; i++) {
290 define void @strong7(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
294 ; CHECK: da analyze - none!
295 ; CHECK: da analyze - none!
296 ; CHECK: da analyze - confused!
297 ; CHECK: da analyze - none!
298 ; CHECK: da analyze - confused!
299 ; CHECK: da analyze - none!
301 for.body: ; preds = %entry, %for.body
302 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
303 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
304 %conv = trunc i64 %i.02 to i32
305 %mul = shl i64 %i.02, 1
306 %add = add i64 %mul, 7
307 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
308 store i32 %conv, i32* %arrayidx, align 4
309 %mul1 = shl i64 %i.02, 1
310 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %mul1
311 %0 = load i32, i32* %arrayidx2, align 4
312 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
313 store i32 %0, i32* %B.addr.01, align 4
314 %inc = add i64 %i.02, 1
315 %exitcond = icmp ne i64 %inc, 20
316 br i1 %exitcond, label %for.body, label %for.end
318 for.end: ; preds = %for.body
323 ;; for (long unsigned i = 0; i < 20; i++) {
327 define void @strong8(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
331 ; CHECK: da analyze - none!
332 ; CHECK: da analyze - flow [*|<]!
333 ; CHECK: da analyze - confused!
334 ; CHECK: da analyze - none!
335 ; CHECK: da analyze - confused!
336 ; CHECK: da analyze - none!
338 for.body: ; preds = %entry, %for.body
339 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
340 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
341 %conv = trunc i64 %i.02 to i32
342 %add = add i64 %i.02, %n
343 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
344 store i32 %conv, i32* %arrayidx, align 4
345 %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %i.02
346 %0 = load i32, i32* %arrayidx1, align 4
347 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
348 store i32 %0, i32* %B.addr.01, align 4
349 %inc = add i64 %i.02, 1
350 %exitcond = icmp ne i64 %inc, 20
351 br i1 %exitcond, label %for.body, label %for.end
353 for.end: ; preds = %for.body
358 ;; for (long unsigned i = 0; i < n; i++) {
360 ;; *B++ = A[i + 2*n];
362 define void @strong9(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
364 %cmp1 = icmp eq i64 %n, 0
365 br i1 %cmp1, label %for.end, label %for.body.preheader
367 ; CHECK: da analyze - none!
368 ; CHECK: da analyze - none!
369 ; CHECK: da analyze - confused!
370 ; CHECK: da analyze - none!
371 ; CHECK: da analyze - confused!
372 ; CHECK: da analyze - none!
374 for.body.preheader: ; preds = %entry
377 for.body: ; preds = %for.body.preheader, %for.body
378 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
379 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
380 %conv = trunc i64 %i.03 to i32
381 %add = add i64 %i.03, %n
382 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
383 store i32 %conv, i32* %arrayidx, align 4
385 %add1 = add i64 %i.03, %mul
386 %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %add1
387 %0 = load i32, i32* %arrayidx2, align 4
388 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
389 store i32 %0, i32* %B.addr.02, align 4
390 %inc = add i64 %i.03, 1
391 %exitcond = icmp ne i64 %inc, %n
392 br i1 %exitcond, label %for.body, label %for.end.loopexit
394 for.end.loopexit: ; preds = %for.body
397 for.end: ; preds = %for.end.loopexit, %entry
402 ;; for (long unsigned i = 0; i < 1000; i++) {
404 ;; *B++ = A[n*i + 5];
406 define void @strong10(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
410 ; CHECK: da analyze - none!
411 ; CHECK: da analyze - consistent flow [0|<]!
412 ; CHECK: da analyze - confused!
413 ; CHECK: da analyze - none!
414 ; CHECK: da analyze - confused!
415 ; CHECK: da analyze - none!
417 for.body: ; preds = %entry, %for.body
418 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
419 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
420 %conv = trunc i64 %i.02 to i32
421 %mul = mul i64 %i.02, %n
422 %add = add i64 %mul, 5
423 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
424 store i32 %conv, i32* %arrayidx, align 4
425 %mul1 = mul i64 %i.02, %n
426 %add2 = add i64 %mul1, 5
427 %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %add2
428 %0 = load i32, i32* %arrayidx3, align 4
429 %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
430 store i32 %0, i32* %B.addr.01, align 4
431 %inc = add i64 %i.02, 1
432 %exitcond = icmp ne i64 %inc, 1000
433 br i1 %exitcond, label %for.body, label %for.end
435 for.end: ; preds = %for.body