1 ; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
3 ; ModuleID = 'SymbolicSIV.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 (long int i = 0; i < n; i++)
10 ;; ... = A[3*i + 3*n];
12 define void @symbolicsiv0(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
14 %cmp1 = icmp eq i64 %n, 0
15 br i1 %cmp1, label %for.end, label %for.body
17 for.body: ; preds = %for.body, %entry
18 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
19 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
20 %conv = trunc i64 %i.03 to i32
21 %mul = shl nsw i64 %i.03, 1
22 %add = add i64 %mul, %n
23 %arrayidx = getelementptr inbounds i32* %A, i64 %add
24 store i32 %conv, i32* %arrayidx, align 4
25 %mul14 = add i64 %i.03, %n
26 %add3 = mul i64 %mul14, 3
27 %arrayidx4 = getelementptr inbounds i32* %A, i64 %add3
28 %0 = load i32* %arrayidx4, align 4
29 ; CHECK: da analyze - none!
30 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
31 store i32 %0, i32* %B.addr.02, align 4
32 %inc = add nsw i64 %i.03, 1
33 %cmp = icmp ult i64 %inc, %n
34 br i1 %cmp, label %for.body, label %for.end
36 for.end: ; preds = %for.body, %entry
41 ;; for (long int i = 0; i < n; i++)
43 ;; ... = A[3*i + 2*n];
45 define void @symbolicsiv1(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
47 %cmp1 = icmp eq i64 %n, 0
48 br i1 %cmp1, label %for.end, label %for.body
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 %conv = trunc i64 %i.03 to i32
54 %mul = shl nsw i64 %i.03, 1
56 %add = add i64 %mul, %mul1
57 %arrayidx = getelementptr inbounds i32* %A, i64 %add
58 store i32 %conv, i32* %arrayidx, align 4
59 %mul2 = mul nsw i64 %i.03, 3
61 %add4 = add i64 %mul2, %mul3
62 %arrayidx5 = getelementptr inbounds i32* %A, i64 %add4
63 %0 = load i32* %arrayidx5, align 4
64 ; CHECK: da analyze - none!
65 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
66 store i32 %0, i32* %B.addr.02, align 4
67 %inc = add nsw i64 %i.03, 1
68 %cmp = icmp ult i64 %inc, %n
69 br i1 %cmp, label %for.body, label %for.end
71 for.end: ; preds = %for.body, %entry
76 ;; for (long int i = 0; i < n; i++)
80 define void @symbolicsiv2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
82 %cmp1 = icmp eq i64 %n, 0
83 br i1 %cmp1, label %for.end, label %for.body
85 for.body: ; preds = %for.body, %entry
86 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
87 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
88 %conv = trunc i64 %i.03 to i32
89 %mul = shl nsw i64 %i.03, 1
90 %sub = sub i64 %mul, %n
91 %arrayidx = getelementptr inbounds i32* %A, i64 %sub
92 store i32 %conv, i32* %arrayidx, align 4
94 %add = sub i64 %mul2, %i.03
95 %arrayidx3 = getelementptr inbounds i32* %A, i64 %add
96 %0 = load i32* %arrayidx3, align 4
97 ; CHECK: da analyze - none!
98 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
99 store i32 %0, i32* %B.addr.02, align 4
100 %inc = add nsw i64 %i.03, 1
101 %cmp = icmp ult i64 %inc, %n
102 br i1 %cmp, label %for.body, label %for.end
104 for.end: ; preds = %for.body, %entry
109 ;; for (long int i = 0; i < n; i++)
110 ;; A[-2*i + n + 1] = ...
113 define void @symbolicsiv3(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
115 %cmp1 = icmp eq i64 %n, 0
116 br i1 %cmp1, label %for.end, label %for.body
118 for.body: ; preds = %for.body, %entry
119 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
120 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
121 %conv = trunc i64 %i.03 to i32
122 %mul = mul nsw i64 %i.03, -2
123 %add = add i64 %mul, %n
124 %add1 = add i64 %add, 1
125 %arrayidx = getelementptr inbounds i32* %A, i64 %add1
126 store i32 %conv, i32* %arrayidx, align 4
127 %mul2 = shl i64 %n, 1
128 %sub = sub i64 %i.03, %mul2
129 %arrayidx3 = getelementptr inbounds i32* %A, i64 %sub
130 %0 = load i32* %arrayidx3, align 4
131 ; CHECK: da analyze - none!
132 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
133 store i32 %0, i32* %B.addr.02, align 4
134 %inc = add nsw i64 %i.03, 1
135 %cmp = icmp ult i64 %inc, %n
136 br i1 %cmp, label %for.body, label %for.end
138 for.end: ; preds = %for.body, %entry
143 ;; for (long int i = 0; i < n; i++)
144 ;; A[-2*i + 3*n] = ...
147 define void @symbolicsiv4(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
149 %cmp1 = icmp eq i64 %n, 0
150 br i1 %cmp1, label %for.end, label %for.body
152 for.body: ; preds = %for.body, %entry
153 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
154 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
155 %conv = trunc i64 %i.03 to i32
156 %mul = mul nsw i64 %i.03, -2
157 %mul1 = mul i64 %n, 3
158 %add = add i64 %mul, %mul1
159 %arrayidx = getelementptr inbounds i32* %A, i64 %add
160 store i32 %conv, i32* %arrayidx, align 4
161 %add2 = sub i64 %n, %i.03
162 %arrayidx3 = getelementptr inbounds i32* %A, i64 %add2
163 %0 = load i32* %arrayidx3, align 4
164 ; CHECK: da analyze - none!
165 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
166 store i32 %0, i32* %B.addr.02, align 4
167 %inc = add nsw i64 %i.03, 1
168 %cmp = icmp ult i64 %inc, %n
169 br i1 %cmp, label %for.body, label %for.end
171 for.end: ; preds = %for.body, %entry
176 ;; for (long int i = 0; i < n; i++)
177 ;; A[-2*i - 2*n] = ...
180 define void @symbolicsiv5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
182 %cmp1 = icmp eq i64 %n, 0
183 br i1 %cmp1, label %for.end, label %for.body
185 for.body: ; preds = %for.body, %entry
186 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
187 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
188 %conv = trunc i64 %i.03 to i32
189 %mul = mul nsw i64 %i.03, -2
190 %mul1 = shl i64 %n, 1
191 %sub = sub i64 %mul, %mul1
192 %arrayidx = getelementptr inbounds i32* %A, i64 %sub
193 store i32 %conv, i32* %arrayidx, align 4
194 %sub2 = sub nsw i64 0, %i.03
195 %sub3 = sub i64 %sub2, %n
196 %arrayidx4 = getelementptr inbounds i32* %A, i64 %sub3
197 %0 = load i32* %arrayidx4, align 4
198 ; CHECK: da analyze - none!
199 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
200 store i32 %0, i32* %B.addr.02, align 4
201 %inc = add nsw i64 %i.03, 1
202 %cmp = icmp ult i64 %inc, %n
203 br i1 %cmp, label %for.body, label %for.end
205 for.end: ; preds = %for.body, %entry
210 ;; why doesn't SCEV package understand that n >= 0?
211 ;;void weaktest(int *A, int *B, long unsigned n)
212 ;; for (long unsigned i = 0; i < n; i++)
213 ;; A[i + n + 1] = ...
216 define void @weaktest(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
218 %cmp1 = icmp eq i64 %n, 0
219 br i1 %cmp1, label %for.end, label %for.body
221 for.body: ; preds = %for.body, %entry
222 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
223 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
224 %conv = trunc i64 %i.03 to i32
225 %add = add i64 %i.03, %n
226 %add1 = add i64 %add, 1
227 %arrayidx = getelementptr inbounds i32* %A, i64 %add1
228 store i32 %conv, i32* %arrayidx, align 4
229 %sub = sub i64 0, %i.03
230 %arrayidx2 = getelementptr inbounds i32* %A, i64 %sub
231 %0 = load i32* %arrayidx2, align 4
232 ; CHECK: da analyze - flow [*|<] splitable!
233 ; CHECK: da analyze - split level = 1, iteration = ((0 smax (-1 + (-1 * %n))) /u 2)!
234 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
235 store i32 %0, i32* %B.addr.02, align 4
236 %inc = add i64 %i.03, 1
237 %cmp = icmp ult i64 %inc, %n
238 br i1 %cmp, label %for.body, label %for.end
240 for.end: ; preds = %for.body, %entry
245 ;; void symbolicsiv6(int *A, int *B, long unsigned n, long unsigned N, long unsigned M) {
246 ;; for (long int i = 0; i < n; i++) {
248 ;; *B++ = A[4*N*i + 3*M + 1];
250 define void @symbolicsiv6(i32* %A, i32* %B, i64 %n, i64 %N, i64 %M) nounwind uwtable ssp {
252 %cmp1 = icmp eq i64 %n, 0
253 br i1 %cmp1, label %for.end, label %for.body.preheader
255 for.body.preheader: ; preds = %entry
258 for.body: ; preds = %for.body.preheader, %for.body
259 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ]
260 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %for.body.preheader ]
261 %conv = trunc i64 %i.03 to i32
263 %mul1 = mul i64 %mul, %i.03
264 %add = add i64 %mul1, %M
265 %arrayidx = getelementptr inbounds i32* %A, i64 %add
266 store i32 %conv, i32* %arrayidx, align 4
267 %mul2 = shl i64 %N, 2
268 %mul3 = mul i64 %mul2, %i.03
269 %mul4 = mul i64 %M, 3
270 %add5 = add i64 %mul3, %mul4
271 %add6 = add i64 %add5, 1
272 %arrayidx7 = getelementptr inbounds i32* %A, i64 %add6
273 %0 = load i32* %arrayidx7, align 4
274 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
275 ; CHECK: da analyze - none!
276 store i32 %0, i32* %B.addr.02, align 4
277 %inc = add nsw i64 %i.03, 1
278 %exitcond = icmp ne i64 %inc, %n
279 br i1 %exitcond, label %for.body, label %for.end.loopexit
281 for.end.loopexit: ; preds = %for.body
284 for.end: ; preds = %for.end.loopexit, %entry
289 ;; void symbolicsiv7(int *A, int *B, long unsigned n, long unsigned N, long unsigned M) {
290 ;; for (long int i = 0; i < n; i++) {
292 ;; *B++ = A[2*N*i - 3*M + 2];
294 define void @symbolicsiv7(i32* %A, i32* %B, i64 %n, i64 %N, i64 %M) nounwind uwtable ssp {
296 %cmp1 = icmp eq i64 %n, 0
297 br i1 %cmp1, label %for.end, label %for.body.preheader
299 for.body.preheader: ; preds = %entry
302 for.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
307 %mul1 = mul i64 %mul, %i.03
308 %add = add i64 %mul1, %M
309 %arrayidx = getelementptr inbounds i32* %A, i64 %add
310 store i32 %conv, i32* %arrayidx, align 4
311 %mul2 = shl i64 %N, 1
312 %mul3 = mul i64 %mul2, %i.03
314 %sub = add i64 %mul3, %0
315 %add5 = add i64 %sub, 2
316 %arrayidx6 = getelementptr inbounds i32* %A, i64 %add5
317 %1 = load i32* %arrayidx6, align 4
318 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
319 ; CHECK: da analyze - flow [<>]!
320 store i32 %1, i32* %B.addr.02, align 4
321 %inc = add nsw i64 %i.03, 1
322 %exitcond = icmp ne i64 %inc, %n
323 br i1 %exitcond, label %for.body, label %for.end.loopexit
325 for.end.loopexit: ; preds = %for.body
328 for.end: ; preds = %for.end.loopexit, %entry