1 ; RUN: opt < %s -analyze -basicaa -indvars -da | FileCheck %s
3 ; ModuleID = 'StrongSIV.bc'
4 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"
5 target triple = "x86_64-apple-macosx10.6.0"
8 ;; for (int i = 0; i < n; i++)
12 define void @strong0(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
14 %cmp1 = icmp sgt i64 %n, 0
15 br i1 %cmp1, label %for.body, label %for.end
17 for.body: ; preds = %for.body, %entry
18 %i.03 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
19 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
20 %add = add nsw i32 %i.03, 2
21 %idxprom = sext i32 %add to i64
22 %arrayidx = getelementptr inbounds i32* %A, i64 %idxprom
23 store i32 %i.03, i32* %arrayidx, align 4
24 %idxprom2 = sext i32 %i.03 to i64
25 %arrayidx3 = getelementptr inbounds i32* %A, i64 %idxprom2
26 %0 = load i32* %arrayidx3, align 4
27 ; CHECK: da analyze - consistent flow [2]!
28 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
29 store i32 %0, i32* %B.addr.02, align 4
30 %inc = add nsw i32 %i.03, 1
31 %conv = sext i32 %inc to i64
32 %cmp = icmp slt i64 %conv, %n
33 br i1 %cmp, label %for.body, label %for.end
35 for.end: ; preds = %for.body, %entry
40 ;; for (long int i = 0; i < n; i++)
44 define void @strong1(i32* %A, i32* %B, i32 %n) nounwind uwtable ssp {
46 %conv = sext i32 %n to i64
47 %cmp1 = icmp sgt i32 %n, 0
48 br i1 %cmp1, label %for.body, label %for.end
50 for.body: ; preds = %for.body, %entry
51 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
52 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
53 %conv2 = trunc i64 %i.03 to i32
54 %add = add nsw i64 %i.03, 2
55 %arrayidx = getelementptr inbounds i32* %A, i64 %add
56 store i32 %conv2, i32* %arrayidx, align 4
57 %arrayidx3 = getelementptr inbounds i32* %A, i64 %i.03
58 %0 = load i32* %arrayidx3, align 4
59 ; CHECK: da analyze - consistent flow [2]!
60 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
61 store i32 %0, i32* %B.addr.02, align 4
62 %inc = add nsw i64 %i.03, 1
63 %cmp = icmp slt i64 %inc, %conv
64 br i1 %cmp, label %for.body, label %for.end
66 for.end: ; preds = %for.body, %entry
71 ;; for (long unsigned i = 0; i < n; i++)
75 define void @strong2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
77 %cmp1 = icmp eq i64 %n, 0
78 br i1 %cmp1, label %for.end, label %for.body
80 for.body: ; preds = %for.body, %entry
81 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
82 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
83 %conv = trunc i64 %i.03 to i32
84 %add = add i64 %i.03, 2
85 %arrayidx = getelementptr inbounds i32* %A, i64 %add
86 store i32 %conv, i32* %arrayidx, align 4
87 %arrayidx1 = getelementptr inbounds i32* %A, i64 %i.03
88 %0 = load i32* %arrayidx1, align 4
89 ; CHECK: da analyze - consistent flow [2]!
90 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
91 store i32 %0, i32* %B.addr.02, align 4
92 %inc = add i64 %i.03, 1
93 %cmp = icmp ult i64 %inc, %n
94 br i1 %cmp, label %for.body, label %for.end
96 for.end: ; preds = %for.body, %entry
101 ;; for (int i = 0; i < n; i++)
105 define void @strong3(i32* %A, i32* %B, i32 %n) nounwind uwtable ssp {
107 %cmp1 = icmp sgt i32 %n, 0
108 br i1 %cmp1, label %for.body, label %for.end
110 for.body: ; preds = %for.body, %entry
111 %i.03 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
112 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
113 %add = add nsw i32 %i.03, 2
114 %idxprom = sext i32 %add to i64
115 %arrayidx = getelementptr inbounds i32* %A, i64 %idxprom
116 store i32 %i.03, i32* %arrayidx, align 4
117 %idxprom1 = sext i32 %i.03 to i64
118 %arrayidx2 = getelementptr inbounds i32* %A, i64 %idxprom1
119 %0 = load i32* %arrayidx2, align 4
120 ; CHECK: da analyze - consistent flow [2]!
121 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
122 store i32 %0, i32* %B.addr.02, align 4
123 %inc = add nsw i32 %i.03, 1
124 %cmp = icmp slt i32 %inc, %n
125 br i1 %cmp, label %for.body, label %for.end
127 for.end: ; preds = %for.body, %entry
132 ;; for (long unsigned i = 0; i < 19; i++)
136 define void @strong4(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
140 for.body: ; preds = %for.body, %entry
141 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
142 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
143 %conv = trunc i64 %i.02 to i32
144 %add = add i64 %i.02, 19
145 %arrayidx = getelementptr inbounds i32* %A, i64 %add
146 store i32 %conv, i32* %arrayidx, align 4
147 %arrayidx1 = getelementptr inbounds i32* %A, i64 %i.02
148 %0 = load i32* %arrayidx1, align 4
149 ; CHECK: da analyze - none!
150 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
151 store i32 %0, i32* %B.addr.01, align 4
152 %inc = add i64 %i.02, 1
153 %cmp = icmp ult i64 %inc, 19
154 br i1 %cmp, label %for.body, label %for.end
156 for.end: ; preds = %for.body
161 ;; for (long unsigned i = 0; i < 20; i++)
165 define void @strong5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
169 for.body: ; preds = %for.body, %entry
170 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
171 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
172 %conv = trunc i64 %i.02 to i32
173 %add = add i64 %i.02, 19
174 %arrayidx = getelementptr inbounds i32* %A, i64 %add
175 store i32 %conv, i32* %arrayidx, align 4
176 %arrayidx1 = getelementptr inbounds i32* %A, i64 %i.02
177 %0 = load i32* %arrayidx1, align 4
178 ; CHECK: da analyze - consistent flow [19]!
179 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
180 store i32 %0, i32* %B.addr.01, align 4
181 %inc = add i64 %i.02, 1
182 %cmp = icmp ult i64 %inc, 20
183 br i1 %cmp, label %for.body, label %for.end
185 for.end: ; preds = %for.body
190 ;; for (long unsigned i = 0; i < 20; i++)
194 define void @strong6(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
198 for.body: ; preds = %for.body, %entry
199 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
200 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
201 %conv = trunc i64 %i.02 to i32
202 %mul = shl i64 %i.02, 1
203 %add = add i64 %mul, 6
204 %arrayidx = getelementptr inbounds i32* %A, i64 %add
205 store i32 %conv, i32* %arrayidx, align 4
206 %mul1 = shl i64 %i.02, 1
207 %arrayidx2 = getelementptr inbounds i32* %A, i64 %mul1
208 %0 = load i32* %arrayidx2, align 4
209 ; CHECK: da analyze - consistent flow [3]!
210 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
211 store i32 %0, i32* %B.addr.01, align 4
212 %inc = add i64 %i.02, 1
213 %cmp = icmp ult i64 %inc, 20
214 br i1 %cmp, label %for.body, label %for.end
216 for.end: ; preds = %for.body
221 ;; for (long unsigned i = 0; i < 20; i++)
225 define void @strong7(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
229 for.body: ; preds = %for.body, %entry
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 %mul = shl i64 %i.02, 1
234 %add = add i64 %mul, 7
235 %arrayidx = getelementptr inbounds i32* %A, i64 %add
236 store i32 %conv, i32* %arrayidx, align 4
237 %mul1 = shl i64 %i.02, 1
238 %arrayidx2 = getelementptr inbounds i32* %A, i64 %mul1
239 %0 = load i32* %arrayidx2, align 4
240 ; CHECK: da analyze - none!
241 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
242 store i32 %0, i32* %B.addr.01, align 4
243 %inc = add i64 %i.02, 1
244 %cmp = icmp ult i64 %inc, 20
245 br i1 %cmp, label %for.body, label %for.end
247 for.end: ; preds = %for.body
252 ;; for (long unsigned i = 0; i < 20; i++)
256 define void @strong8(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
260 for.body: ; preds = %for.body, %entry
261 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
262 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
263 %conv = trunc i64 %i.02 to i32
264 %add = add i64 %i.02, %n
265 %arrayidx = getelementptr inbounds i32* %A, i64 %add
266 store i32 %conv, i32* %arrayidx, align 4
267 %arrayidx1 = getelementptr inbounds i32* %A, i64 %i.02
268 %0 = load i32* %arrayidx1, align 4
269 ; CHECK: da analyze - consistent flow [%n|<]!
270 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
271 store i32 %0, i32* %B.addr.01, align 4
272 %inc = add i64 %i.02, 1
273 %cmp = icmp ult i64 %inc, 20
274 br i1 %cmp, label %for.body, label %for.end
276 for.end: ; preds = %for.body
281 ;; for (long unsigned i = 0; i < n; i++)
285 define void @strong9(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
287 %cmp1 = icmp eq i64 %n, 0
288 br i1 %cmp1, label %for.end, label %for.body
290 for.body: ; preds = %for.body, %entry
291 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
292 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
293 %conv = trunc i64 %i.03 to i32
294 %add = add i64 %i.03, %n
295 %arrayidx = getelementptr inbounds i32* %A, i64 %add
296 store i32 %conv, i32* %arrayidx, align 4
298 %add1 = add i64 %i.03, %mul
299 %arrayidx2 = getelementptr inbounds i32* %A, i64 %add1
300 %0 = load i32* %arrayidx2, align 4
301 ; CHECK: da analyze - none!
302 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
303 store i32 %0, i32* %B.addr.02, align 4
304 %inc = add i64 %i.03, 1
305 %cmp = icmp ult i64 %inc, %n
306 br i1 %cmp, label %for.body, label %for.end
308 for.end: ; preds = %for.body, %entry
313 ;; for (long unsigned i = 0; i < 1000; i++)
317 define void @strong10(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
321 for.body: ; preds = %for.body, %entry
322 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
323 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
324 %conv = trunc i64 %i.02 to i32
325 %mul = mul i64 %i.02, %n
326 %add = add i64 %mul, 5
327 %arrayidx = getelementptr inbounds i32* %A, i64 %add
328 store i32 %conv, i32* %arrayidx, align 4
329 %mul1 = mul i64 %i.02, %n
330 %add2 = add i64 %mul1, 5
331 %arrayidx3 = getelementptr inbounds i32* %A, i64 %add2
332 %0 = load i32* %arrayidx3, align 4
333 ; CHECK: da analyze - consistent flow [0|<]!
334 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
335 store i32 %0, i32* %B.addr.01, align 4
336 %inc = add i64 %i.02, 1
337 %cmp = icmp ult i64 %inc, 1000
338 br i1 %cmp, label %for.body, label %for.end
340 for.end: ; preds = %for.body