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 = 'WeakCrossingSIV.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 unsigned i = 0; i < n; i++) {
11;;    A[1 + n*i] = i;
12;;    *B++ = A[1 - n*i];
13
14define void @weakcrossing0(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
15entry:
16  %cmp1 = icmp eq i64 %n, 0
17  br i1 %cmp1, label %for.end, label %for.body.preheader
18
19for.body.preheader:                               ; preds = %entry
20  br label %for.body
21
22; CHECK: da analyze - none!
23; CHECK: da analyze - flow [0|<]!
24; CHECK: da analyze - confused!
25; CHECK: da analyze - none!
26; CHECK: da analyze - confused!
27; CHECK: da analyze - none!
28
29for.body:                                         ; preds = %for.body.preheader, %for.body
30  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
31  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
32  %conv = trunc i64 %i.03 to i32
33  %mul = mul i64 %i.03, %n
34  %add = add i64 %mul, 1
35  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
36  store i32 %conv, i32* %arrayidx, align 4
37  %mul1 = mul i64 %i.03, %n
38  %sub = sub i64 1, %mul1
39  %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %sub
40  %0 = load i32, i32* %arrayidx2, align 4
41  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
42  store i32 %0, i32* %B.addr.02, align 4
43  %inc = add i64 %i.03, 1
44  %exitcond = icmp ne i64 %inc, %n
45  br i1 %exitcond, label %for.body, label %for.end.loopexit
46
47for.end.loopexit:                                 ; preds = %for.body
48  br label %for.end
49
50for.end:                                          ; preds = %for.end.loopexit, %entry
51  ret void
52}
53
54
55;;  for (long unsigned i = 0; i < n; i++) {
56;;    A[n + i] = i;
57;;    *B++ = A[1 + n - i];
58
59define void @weakcrossing1(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
60entry:
61  %cmp1 = icmp eq i64 %n, 0
62  br i1 %cmp1, label %for.end, label %for.body.preheader
63
64; CHECK: da analyze - none!
65; CHECK: da analyze - flow [<>] splitable!
66; CHECK: da analyze - split level = 1, iteration = 0!
67; CHECK: da analyze - confused!
68; CHECK: da analyze - none!
69; CHECK: da analyze - confused!
70; CHECK: da analyze - none!
71
72for.body.preheader:                               ; preds = %entry
73  br label %for.body
74
75for.body:                                         ; preds = %for.body.preheader, %for.body
76  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
77  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
78  %conv = trunc i64 %i.03 to i32
79  %add = add i64 %i.03, %n
80  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %add
81  store i32 %conv, i32* %arrayidx, align 4
82  %add1 = add i64 %n, 1
83  %sub = sub i64 %add1, %i.03
84  %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %sub
85  %0 = load i32, i32* %arrayidx2, align 4
86  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
87  store i32 %0, i32* %B.addr.02, align 4
88  %inc = add i64 %i.03, 1
89  %exitcond = icmp ne i64 %inc, %n
90  br i1 %exitcond, label %for.body, label %for.end.loopexit
91
92for.end.loopexit:                                 ; preds = %for.body
93  br label %for.end
94
95for.end:                                          ; preds = %for.end.loopexit, %entry
96  ret void
97}
98
99
100;;  for (long unsigned i = 0; i < 3; i++) {
101;;    A[i] = i;
102;;    *B++ = A[6 - i];
103
104define void @weakcrossing2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
105entry:
106  br label %for.body
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:                                         ; preds = %entry, %for.body
116  %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
117  %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
118  %conv = trunc i64 %i.02 to i32
119  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.02
120  store i32 %conv, i32* %arrayidx, align 4
121  %sub = sub i64 6, %i.02
122  %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %sub
123  %0 = load i32, i32* %arrayidx1, align 4
124  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
125  store i32 %0, i32* %B.addr.01, align 4
126  %inc = add i64 %i.02, 1
127  %exitcond = icmp ne i64 %inc, 3
128  br i1 %exitcond, label %for.body, label %for.end
129
130for.end:                                          ; preds = %for.body
131  ret void
132}
133
134
135;;  for (long unsigned i = 0; i < 4; i++) {
136;;    A[i] = i;
137;;    *B++ = A[6 - i];
138
139define void @weakcrossing3(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
140entry:
141  br label %for.body
142
143; CHECK: da analyze - none!
144; CHECK: da analyze - flow [0|<]!
145; CHECK: da analyze - confused!
146; CHECK: da analyze - none!
147; CHECK: da analyze - confused!
148; CHECK: da analyze - none!
149
150for.body:                                         ; preds = %entry, %for.body
151  %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
152  %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
153  %conv = trunc i64 %i.02 to i32
154  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.02
155  store i32 %conv, i32* %arrayidx, align 4
156  %sub = sub i64 6, %i.02
157  %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %sub
158  %0 = load i32, i32* %arrayidx1, align 4
159  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
160  store i32 %0, i32* %B.addr.01, align 4
161  %inc = add i64 %i.02, 1
162  %exitcond = icmp ne i64 %inc, 4
163  br i1 %exitcond, label %for.body, label %for.end
164
165for.end:                                          ; preds = %for.body
166  ret void
167}
168
169
170;;  for (long unsigned i = 0; i < 10; i++) {
171;;    A[i] = i;
172;;    *B++ = A[-6 - i];
173
174define void @weakcrossing4(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
175entry:
176  br label %for.body
177
178; CHECK: da analyze - none!
179; CHECK: da analyze - none!
180; CHECK: da analyze - confused!
181; CHECK: da analyze - none!
182; CHECK: da analyze - confused!
183; CHECK: da analyze - none!
184
185for.body:                                         ; preds = %entry, %for.body
186  %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
187  %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
188  %conv = trunc i64 %i.02 to i32
189  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.02
190  store i32 %conv, i32* %arrayidx, align 4
191  %sub = sub i64 -6, %i.02
192  %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %sub
193  %0 = load i32, i32* %arrayidx1, align 4
194  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
195  store i32 %0, i32* %B.addr.01, align 4
196  %inc = add i64 %i.02, 1
197  %exitcond = icmp ne i64 %inc, 10
198  br i1 %exitcond, label %for.body, label %for.end
199
200for.end:                                          ; preds = %for.body
201  ret void
202}
203
204
205;;  for (long unsigned i = 0; i < n; i++) {
206;;    A[3*i] = i;
207;;    *B++ = A[5 - 3*i];
208
209define void @weakcrossing5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
210entry:
211  %cmp1 = icmp eq i64 %n, 0
212  br i1 %cmp1, label %for.end, label %for.body.preheader
213
214; CHECK: da analyze - none!
215; CHECK: da analyze - none!
216; CHECK: da analyze - confused!
217; CHECK: da analyze - none!
218; CHECK: da analyze - confused!
219; CHECK: da analyze - none!
220
221for.body.preheader:                               ; preds = %entry
222  br label %for.body
223
224for.body:                                         ; preds = %for.body.preheader, %for.body
225  %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
226  %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
227  %conv = trunc i64 %i.03 to i32
228  %mul = mul i64 %i.03, 3
229  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %mul
230  store i32 %conv, i32* %arrayidx, align 4
231  %0 = mul i64 %i.03, -3
232  %sub = add i64 %0, 5
233  %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %sub
234  %1 = load i32, i32* %arrayidx2, align 4
235  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.02, i64 1
236  store i32 %1, i32* %B.addr.02, align 4
237  %inc = add i64 %i.03, 1
238  %exitcond = icmp ne i64 %inc, %n
239  br i1 %exitcond, label %for.body, label %for.end.loopexit
240
241for.end.loopexit:                                 ; preds = %for.body
242  br label %for.end
243
244for.end:                                          ; preds = %for.end.loopexit, %entry
245  ret void
246}
247
248
249;;  for (long unsigned i = 0; i < 4; i++) {
250;;    A[i] = i;
251;;    *B++ = A[5 - i];
252
253define void @weakcrossing6(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
254entry:
255  br label %for.body
256
257; CHECK: da analyze - none!
258; CHECK: da analyze - flow [<>] splitable!
259; CHECK: da analyze - split level = 1, iteration = 2!
260; CHECK: da analyze - confused!
261; CHECK: da analyze - none!
262; CHECK: da analyze - confused!
263; CHECK: da analyze - none!
264
265for.body:                                         ; preds = %entry, %for.body
266  %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
267  %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
268  %conv = trunc i64 %i.02 to i32
269  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.02
270  store i32 %conv, i32* %arrayidx, align 4
271  %sub = sub i64 5, %i.02
272  %arrayidx1 = getelementptr inbounds i32, i32* %A, i64 %sub
273  %0 = load i32, i32* %arrayidx1, align 4
274  %incdec.ptr = getelementptr inbounds i32, i32* %B.addr.01, i64 1
275  store i32 %0, i32* %B.addr.01, align 4
276  %inc = add i64 %i.02, 1
277  %exitcond = icmp ne i64 %inc, 4
278  br i1 %exitcond, label %for.body, label %for.end
279
280for.end:                                          ; preds = %for.body
281  ret void
282}
283