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