1 ; RUN: opt < %s -analyze -basicaa -da | FileCheck %s
3 ; ModuleID = 'WeakCrossingSIV.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 unsigned i = 0; i < n; i++)
12 define void @weakcrossing0(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 = mul i64 %i.03, %n
22 %add = add i64 %mul, 1
23 %arrayidx = getelementptr inbounds i32* %A, i64 %add
24 store i32 %conv, i32* %arrayidx, align 4
25 %mul1 = mul i64 %i.03, %n
26 %sub = sub i64 1, %mul1
27 %arrayidx2 = getelementptr inbounds i32* %A, i64 %sub
28 %0 = load i32* %arrayidx2, align 4
29 ; CHECK: da analyze - flow [0|<]!
30 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
31 store i32 %0, i32* %B.addr.02, align 4
32 %inc = add 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 unsigned i = 0; i < n; i++)
43 ;; ... = A[1 + n - i];
45 define void @weakcrossing1(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 %add = add i64 %i.03, %n
55 %arrayidx = getelementptr inbounds i32* %A, i64 %add
56 store i32 %conv, i32* %arrayidx, align 4
58 %sub = sub i64 %add1, %i.03
59 %arrayidx2 = getelementptr inbounds i32* %A, i64 %sub
60 %0 = load i32* %arrayidx2, align 4
61 ; CHECK: da analyze - flow [<>] splitable!
62 ; CHECK: da analyze - split level = 1, iteration = 0!
63 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
64 store i32 %0, i32* %B.addr.02, align 4
65 %inc = add i64 %i.03, 1
66 %cmp = icmp ult i64 %inc, %n
67 br i1 %cmp, label %for.body, label %for.end
69 for.end: ; preds = %for.body, %entry
74 ;; for (long unsigned i = 0; i < 3; i++)
78 define void @weakcrossing2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
82 for.body: ; preds = %for.body, %entry
83 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
84 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
85 %conv = trunc i64 %i.02 to i32
86 %arrayidx = getelementptr inbounds i32* %A, i64 %i.02
87 store i32 %conv, i32* %arrayidx, align 4
88 %sub = sub i64 6, %i.02
89 %arrayidx1 = getelementptr inbounds i32* %A, i64 %sub
90 %0 = load i32* %arrayidx1, align 4
91 ; CHECK: da analyze - none!
92 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
93 store i32 %0, i32* %B.addr.01, align 4
94 %inc = add i64 %i.02, 1
95 %cmp = icmp ult i64 %inc, 3
96 br i1 %cmp, label %for.body, label %for.end
98 for.end: ; preds = %for.body
103 ;; for (long unsigned i = 0; i < 4; i++)
107 define void @weakcrossing3(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
111 for.body: ; preds = %for.body, %entry
112 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
113 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
114 %conv = trunc i64 %i.02 to i32
115 %arrayidx = getelementptr inbounds i32* %A, i64 %i.02
116 store i32 %conv, i32* %arrayidx, align 4
117 %sub = sub i64 6, %i.02
118 %arrayidx1 = getelementptr inbounds i32* %A, i64 %sub
119 %0 = load i32* %arrayidx1, align 4
120 ; CHECK: da analyze - flow [0|<]!
121 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
122 store i32 %0, i32* %B.addr.01, align 4
123 %inc = add i64 %i.02, 1
124 %cmp = icmp ult i64 %inc, 4
125 br i1 %cmp, label %for.body, label %for.end
127 for.end: ; preds = %for.body
132 ;; for (long unsigned i = 0; i < 10; i++)
136 define void @weakcrossing4(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 %arrayidx = getelementptr inbounds i32* %A, i64 %i.02
145 store i32 %conv, i32* %arrayidx, align 4
146 %sub = sub i64 -6, %i.02
147 %arrayidx1 = getelementptr inbounds i32* %A, i64 %sub
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, 10
154 br i1 %cmp, label %for.body, label %for.end
156 for.end: ; preds = %for.body
161 ;; for (long unsigned i = 0; i < n; i++)
165 define void @weakcrossing5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
167 %cmp1 = icmp eq i64 %n, 0
168 br i1 %cmp1, label %for.end, label %for.body
170 for.body: ; preds = %for.body, %entry
171 %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
172 %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
173 %conv = trunc i64 %i.03 to i32
174 %mul = mul i64 %i.03, 3
175 %arrayidx = getelementptr inbounds i32* %A, i64 %mul
176 store i32 %conv, i32* %arrayidx, align 4
177 %0 = mul i64 %i.03, -3
179 %arrayidx2 = getelementptr inbounds i32* %A, i64 %sub
180 %1 = load i32* %arrayidx2, align 4
181 ; CHECK: da analyze - none!
182 %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
183 store i32 %1, i32* %B.addr.02, align 4
184 %inc = add i64 %i.03, 1
185 %cmp = icmp ult i64 %inc, %n
186 br i1 %cmp, label %for.body, label %for.end
188 for.end: ; preds = %for.body, %entry
193 ;; for (long unsigned i = 0; i < 4; i++)
197 define void @weakcrossing6(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
201 for.body: ; preds = %for.body, %entry
202 %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
203 %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
204 %conv = trunc i64 %i.02 to i32
205 %arrayidx = getelementptr inbounds i32* %A, i64 %i.02
206 store i32 %conv, i32* %arrayidx, align 4
207 %sub = sub i64 5, %i.02
208 %arrayidx1 = getelementptr inbounds i32* %A, i64 %sub
209 %0 = load i32* %arrayidx1, align 4
210 ; CHECK: da analyze - flow [<>] splitable!
211 ; CHECK: da analyze - split level = 1, iteration = 2!
212 %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
213 store i32 %0, i32* %B.addr.01, align 4
214 %inc = add i64 %i.02, 1
215 %cmp = icmp ult i64 %inc, 4
216 br i1 %cmp, label %for.body, label %for.end
218 for.end: ; preds = %for.body