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