• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
2
3target 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"
4target triple = "x86_64-apple-macosx10.6.0"
5
6
7;;  for (long int i = 0; i < n; i++) {
8;;    A[2*i + n] = i;
9;;    *B++ = A[3*i + 3*n];
10
11define void @symbolicsiv0(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
12entry:
13  %cmp1 = icmp eq i64 %n, 0
14  br i1 %cmp1, label %for.end, label %for.body.preheader
15
16; CHECK: da analyze - none!
17; CHECK: da analyze - none!
18; CHECK: da analyze - confused!
19; CHECK: da analyze - none!
20; CHECK: da analyze - confused!
21; CHECK: da analyze - none!
22
23for.body.preheader:                               ; preds = %entry
24  br label %for.body
25
26for.body:                                         ; preds = %for.body.preheader, %for.body
27  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
28  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
29  %conv = trunc i64 %i.03 to i32
30  %mul = shl nsw i64 %i.03, 1
31  %add = add i64 %mul, %n
32  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
33  store i32 %conv, i32* %arrayidx, align 4
34  %mul14 = add i64 %i.03, %n
35  %add3 = mul i64 %mul14, 3
36  %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %add3
37  %0 = load i32, i32* %arrayidx4, align 4
38  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
39  store i32 %0, i32* %B.addr.02, align 4
40  %inc = add nsw i64 %i.03, 1
41  %exitcond = icmp ne i64 %inc, %n
42  br i1 %exitcond, label %for.body, label %for.end.loopexit
43
44for.end.loopexit:                                 ; preds = %for.body
45  br label %for.end
46
47for.end:                                          ; preds = %for.end.loopexit, %entry
48  ret void
49}
50
51
52;;  for (long int i = 0; i < n; i++) {
53;;    A[2*i + 5*n] = i;
54;;    *B++ = A[3*i + 2*n];
55
56define void @symbolicsiv1(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
57entry:
58  %cmp1 = icmp eq i64 %n, 0
59  br i1 %cmp1, label %for.end, label %for.body.preheader
60
61; CHECK: da analyze - none!
62; CHECK: da analyze - none!
63; CHECK: da analyze - confused!
64; CHECK: da analyze - none!
65; CHECK: da analyze - confused!
66; CHECK: da analyze - none!
67
68for.body.preheader:                               ; preds = %entry
69  br label %for.body
70
71for.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  %conv = trunc i64 %i.03 to i32
75  %mul = shl nsw i64 %i.03, 1
76  %mul1 = mul i64 %n, 5
77  %add = add i64 %mul, %mul1
78  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
79  store i32 %conv, i32* %arrayidx, align 4
80  %mul2 = mul nsw i64 %i.03, 3
81  %mul3 = shl i64 %n, 1
82  %add4 = add i64 %mul2, %mul3
83  %arrayidx5 = getelementptr inbounds i32, i32* %A, i64 %add4
84  %0 = load i32, i32* %arrayidx5, align 4
85  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
86  store i32 %0, i32* %B.addr.02, align 4
87  %inc = add nsw i64 %i.03, 1
88  %exitcond = icmp ne i64 %inc, %n
89  br i1 %exitcond, label %for.body, label %for.end.loopexit
90
91for.end.loopexit:                                 ; preds = %for.body
92  br label %for.end
93
94for.end:                                          ; preds = %for.end.loopexit, %entry
95  ret void
96}
97
98
99;;  for (long int i = 0; i < n; i++) {
100;;    A[2*i - n] = i;
101;;    *B++ = A[-i + 2*n];
102
103define void @symbolicsiv2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
104entry:
105  %cmp1 = icmp eq i64 %n, 0
106  br i1 %cmp1, label %for.end, label %for.body.preheader
107
108; CHECK: da analyze - none!
109; CHECK: da analyze - none!
110; CHECK: da analyze - confused!
111; CHECK: da analyze - none!
112; CHECK: da analyze - confused!
113; CHECK: da analyze - none!
114
115for.body.preheader:                               ; preds = %entry
116  br label %for.body
117
118for.body:                                         ; preds = %for.body.preheader, %for.body
119  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
120  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
121  %conv = trunc i64 %i.03 to i32
122  %mul = shl nsw i64 %i.03, 1
123  %sub = sub i64 %mul, %n
124  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %sub
125  store i32 %conv, i32* %arrayidx, align 4
126  %mul2 = shl i64 %n, 1
127  %add = sub i64 %mul2, %i.03
128  %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %add
129  %0 = load i32, i32* %arrayidx3, align 4
130  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
131  store i32 %0, i32* %B.addr.02, align 4
132  %inc = add nsw i64 %i.03, 1
133  %exitcond = icmp ne i64 %inc, %n
134  br i1 %exitcond, label %for.body, label %for.end.loopexit
135
136for.end.loopexit:                                 ; preds = %for.body
137  br label %for.end
138
139for.end:                                          ; preds = %for.end.loopexit, %entry
140  ret void
141}
142
143
144;;  for (long int i = 0; i < n; i++) {
145;;    A[-2*i + n + 1] = i;
146;;    *B++ = A[i - 2*n];
147
148define void @symbolicsiv3(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
149entry:
150  %cmp1 = icmp eq i64 %n, 0
151  br i1 %cmp1, label %for.end, label %for.body.preheader
152
153; CHECK: da analyze - none!
154; CHECK: da analyze - none!
155; CHECK: da analyze - confused!
156; CHECK: da analyze - none!
157; CHECK: da analyze - confused!
158; CHECK: da analyze - none!
159
160for.body.preheader:                               ; preds = %entry
161  br label %for.body
162
163for.body:                                         ; preds = %for.body.preheader, %for.body
164  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
165  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
166  %conv = trunc i64 %i.03 to i32
167  %mul = mul nsw i64 %i.03, -2
168  %add = add i64 %mul, %n
169  %add1 = add i64 %add, 1
170  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add1
171  store i32 %conv, i32* %arrayidx, align 4
172  %mul2 = shl i64 %n, 1
173  %sub = sub i64 %i.03, %mul2
174  %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %sub
175  %0 = load i32, i32* %arrayidx3, align 4
176  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
177  store i32 %0, i32* %B.addr.02, align 4
178  %inc = add nsw i64 %i.03, 1
179  %exitcond = icmp ne i64 %inc, %n
180  br i1 %exitcond, label %for.body, label %for.end.loopexit
181
182for.end.loopexit:                                 ; preds = %for.body
183  br label %for.end
184
185for.end:                                          ; preds = %for.end.loopexit, %entry
186  ret void
187}
188
189
190;;  for (long int i = 0; i < n; i++) {
191;;    A[-2*i + 3*n] = i;
192;;    *B++ = A[-i + n];
193
194define void @symbolicsiv4(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
195entry:
196  %cmp1 = icmp eq i64 %n, 0
197  br i1 %cmp1, label %for.end, label %for.body.preheader
198
199; CHECK: da analyze - none!
200; CHECK: da analyze - none!
201; CHECK: da analyze - confused!
202; CHECK: da analyze - none!
203; CHECK: da analyze - confused!
204; CHECK: da analyze - none!
205
206for.body.preheader:                               ; preds = %entry
207  br label %for.body
208
209for.body:                                         ; preds = %for.body.preheader, %for.body
210  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
211  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
212  %conv = trunc i64 %i.03 to i32
213  %mul = mul nsw i64 %i.03, -2
214  %mul1 = mul i64 %n, 3
215  %add = add i64 %mul, %mul1
216  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
217  store i32 %conv, i32* %arrayidx, align 4
218  %add2 = sub i64 %n, %i.03
219  %arrayidx3 = getelementptr inbounds i32, i32* %A, i64 %add2
220  %0 = load i32, i32* %arrayidx3, align 4
221  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
222  store i32 %0, i32* %B.addr.02, align 4
223  %inc = add nsw i64 %i.03, 1
224  %exitcond = icmp ne i64 %inc, %n
225  br i1 %exitcond, label %for.body, label %for.end.loopexit
226
227for.end.loopexit:                                 ; preds = %for.body
228  br label %for.end
229
230for.end:                                          ; preds = %for.end.loopexit, %entry
231  ret void
232}
233
234
235;;  for (long int i = 0; i < n; i++) {
236;;    A[-2*i - 2*n] = i;
237;;    *B++ = A[-i - n];
238
239define void @symbolicsiv5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
240entry:
241  %cmp1 = icmp eq i64 %n, 0
242  br i1 %cmp1, label %for.end, label %for.body.preheader
243
244; CHECK: da analyze - none!
245; CHECK: da analyze - none!
246; CHECK: da analyze - confused!
247; CHECK: da analyze - none!
248; CHECK: da analyze - confused!
249; CHECK: da analyze - none!
250
251for.body.preheader:                               ; preds = %entry
252  br label %for.body
253
254for.body:                                         ; preds = %for.body.preheader, %for.body
255  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
256  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
257  %conv = trunc i64 %i.03 to i32
258  %mul = mul nsw i64 %i.03, -2
259  %mul1 = shl i64 %n, 1
260  %sub = sub i64 %mul, %mul1
261  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %sub
262  store i32 %conv, i32* %arrayidx, align 4
263  %sub2 = sub nsw i64 0, %i.03
264  %sub3 = sub i64 %sub2, %n
265  %arrayidx4 = getelementptr inbounds i32, i32* %A, i64 %sub3
266  %0 = load i32, i32* %arrayidx4, align 4
267  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
268  store i32 %0, i32* %B.addr.02, align 4
269  %inc = add nsw i64 %i.03, 1
270  %exitcond = icmp ne i64 %inc, %n
271  br i1 %exitcond, label %for.body, label %for.end.loopexit
272
273for.end.loopexit:                                 ; preds = %for.body
274  br label %for.end
275
276for.end:                                          ; preds = %for.end.loopexit, %entry
277  ret void
278}
279
280
281;; why doesn't SCEV package understand that n >= 0?
282;;  for (long unsigned i = 0; i < n; i++) {
283;;    A[i + n + 1] = i;
284;;    *B++ = A[-i];
285
286define void @weaktest(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
287entry:
288  %cmp1 = icmp eq i64 %n, 0
289  br i1 %cmp1, label %for.end, label %for.body.preheader
290
291; CHECK: da analyze - none!
292; CHECK: da analyze - flow [*|<] splitable!
293; CHECK: da analyze - split level = 1, iteration = ((0 smax (-4 + (-4 * %n))) /u 8)!
294; CHECK: da analyze - confused!
295; CHECK: da analyze - none!
296; CHECK: da analyze - confused!
297; CHECK: da analyze - none!
298
299for.body.preheader:                               ; preds = %entry
300  br label %for.body
301
302for.body:                                         ; preds = %for.body.preheader, %for.body
303  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
304  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
305  %conv = trunc i64 %i.03 to i32
306  %add = add i64 %i.03, %n
307  %add1 = add i64 %add, 1
308  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add1
309  store i32 %conv, i32* %arrayidx, align 4
310  %sub = sub i64 0, %i.03
311  %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %sub
312  %0 = load i32, i32* %arrayidx2, align 4
313  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
314  store i32 %0, i32* %B.addr.02, align 4
315  %inc = add i64 %i.03, 1
316  %exitcond = icmp ne i64 %inc, %n
317  br i1 %exitcond, label %for.body, label %for.end.loopexit
318
319for.end.loopexit:                                 ; preds = %for.body
320  br label %for.end
321
322for.end:                                          ; preds = %for.end.loopexit, %entry
323  ret void
324}
325
326
327;;  for (long int i = 0; i < n; i++) {
328;;    A[4*N*i + M] = i;
329;;    *B++ = A[4*N*i + 3*M + 1];
330
331define void @symbolicsiv6(i32* %A, i32* %B, i64 %n, i64 %N, i64 %M) nounwind uwtable ssp {
332entry:
333  %cmp1 = icmp eq i64 %n, 0
334  br i1 %cmp1, label %for.end, label %for.body.preheader
335
336; CHECK-LABEL: symbolicsiv6
337; CHECK: da analyze - none!
338; CHECK: da analyze - none!
339; CHECK: da analyze - confused!
340; CHECK: da analyze - none!
341; CHECK: da analyze - confused!
342; CHECK: da analyze - none!
343
344for.body.preheader:                               ; preds = %entry
345  br label %for.body
346
347for.body:                                         ; preds = %for.body.preheader, %for.body
348  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
349  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
350  %conv = trunc i64 %i.03 to i32
351  %mul = shl i64 %N, 2
352  %mul1 = mul i64 %mul, %i.03
353  %add = add i64 %mul1, %M
354  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
355  store i32 %conv, i32* %arrayidx, align 4
356  %mul2 = shl i64 %N, 2
357  %mul3 = mul i64 %mul2, %i.03
358  %mul4 = mul i64 %M, 3
359  %add5 = add i64 %mul3, %mul4
360  %add6 = add i64 %add5, 1
361  %arrayidx7 = getelementptr inbounds i32, i32* %A, i64 %add6
362  %0 = load i32, i32* %arrayidx7, align 4
363  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
364  store i32 %0, i32* %B.addr.02, align 4
365  %inc = add nsw i64 %i.03, 1
366  %exitcond = icmp ne i64 %inc, %n
367  br i1 %exitcond, label %for.body, label %for.end.loopexit
368
369for.end.loopexit:                                 ; preds = %for.body
370  br label %for.end
371
372for.end:                                          ; preds = %for.end.loopexit, %entry
373  ret void
374}
375
376
377;;  for (long int i = 0; i < n; i++) {
378;;    A[2*N*i + M] = i;
379;;    *B++ = A[2*N*i - 3*M + 2];
380
381define void @symbolicsiv7(i32* %A, i32* %B, i64 %n, i64 %N, i64 %M) nounwind uwtable ssp {
382entry:
383  %cmp1 = icmp eq i64 %n, 0
384  br i1 %cmp1, label %for.end, label %for.body.preheader
385; CHECK-LABEL: symbolicsiv7
386; CHECK: da analyze - none!
387; CHECK: da analyze - flow [<>]!
388; CHECK: da analyze - confused!
389; CHECK: da analyze - none!
390; CHECK: da analyze - confused!
391; CHECK: da analyze - none!
392
393for.body.preheader:                               ; preds = %entry
394  br label %for.body
395
396for.body:                                         ; preds = %for.body.preheader, %for.body
397  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
398  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
399  %conv = trunc i64 %i.03 to i32
400  %mul = shl i64 %N, 1
401  %mul1 = mul i64 %mul, %i.03
402  %add = add i64 %mul1, %M
403  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
404  store i32 %conv, i32* %arrayidx, align 4
405  %mul2 = shl i64 %N, 1
406  %mul3 = mul i64 %mul2, %i.03
407  %0 = mul i64 %M, -3
408  %sub = add i64 %mul3, %0
409  %add5 = add i64 %sub, 2
410  %arrayidx6 = getelementptr inbounds i32, i32* %A, i64 %add5
411  %1 = load i32, i32* %arrayidx6, align 4
412  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
413  store i32 %1, i32* %B.addr.02, align 4
414  %inc = add nsw i64 %i.03, 1
415  %exitcond = icmp ne i64 %inc, %n
416  br i1 %exitcond, label %for.body, label %for.end.loopexit
417
418for.end.loopexit:                                 ; preds = %for.body
419  br label %for.end
420
421for.end:                                          ; preds = %for.end.loopexit, %entry
422  ret void
423}
424