OSDN Git Service

dependence analysis
[android-x86/external-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] = ...
10 ;;    ... = 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 for.body:                                         ; preds = %for.body, %entry
17   %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
18   %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
19   %conv = trunc i64 %i.02 to i32
20   %mul = shl i64 %i.02, 1
21   %add = add i64 %mul, 10
22   %arrayidx = getelementptr inbounds i32* %A, i64 %add
23   store i32 %conv, i32* %arrayidx, align 4
24   %arrayidx1 = getelementptr inbounds i32* %A, i64 10
25   %0 = load i32* %arrayidx1, align 4
26 ; CHECK: da analyze - flow [p<=|<]!
27   %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
28   store i32 %0, i32* %B.addr.01, align 4
29   %inc = add i64 %i.02, 1
30   %cmp = icmp ult i64 %inc, 30
31   br i1 %cmp, label %for.body, label %for.end
32
33 for.end:                                          ; preds = %for.body
34   ret void
35 }
36
37
38 ;;  for (long unsigned i = 0; i < n; i++)
39 ;;    A[n*i + 10] = ...
40 ;;    ... = A[10];
41
42 define void @weakzerodst1(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
43 entry:
44   %cmp1 = icmp eq i64 %n, 0
45   br i1 %cmp1, label %for.end, label %for.body
46
47 for.body:                                         ; preds = %for.body, %entry
48   %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
49   %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
50   %conv = trunc i64 %i.03 to i32
51   %mul = mul i64 %i.03, %n
52   %add = add i64 %mul, 10
53   %arrayidx = getelementptr inbounds i32* %A, i64 %add
54   store i32 %conv, i32* %arrayidx, align 4
55   %arrayidx1 = getelementptr inbounds i32* %A, i64 10
56   %0 = load i32* %arrayidx1, align 4
57 ; CHECK: da analyze - flow [p<=|<]!
58   %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
59   store i32 %0, i32* %B.addr.02, align 4
60   %inc = add i64 %i.03, 1
61   %cmp = icmp ult i64 %inc, %n
62   br i1 %cmp, label %for.body, label %for.end
63
64 for.end:                                          ; preds = %for.body, %entry
65   ret void
66 }
67
68
69 ;;  for (long unsigned i = 0; i < 5; i++)
70 ;;    A[2*i] = ...
71 ;;    ... = A[10];
72
73 define void @weakzerodst2(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
74 entry:
75   br label %for.body
76
77 for.body:                                         ; preds = %for.body, %entry
78   %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
79   %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
80   %conv = trunc i64 %i.02 to i32
81   %mul = shl i64 %i.02, 1
82   %arrayidx = getelementptr inbounds i32* %A, i64 %mul
83   store i32 %conv, i32* %arrayidx, align 4
84   %arrayidx1 = getelementptr inbounds i32* %A, i64 10
85   %0 = load i32* %arrayidx1, align 4
86 ; CHECK: da analyze - none!
87   %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
88   store i32 %0, i32* %B.addr.01, align 4
89   %inc = add i64 %i.02, 1
90   %cmp = icmp ult i64 %inc, 5
91   br i1 %cmp, label %for.body, label %for.end
92
93 for.end:                                          ; preds = %for.body
94   ret void
95 }
96
97
98 ;;  for (long unsigned i = 0; i < 6; i++)
99 ;;    A[2*i] = ...
100 ;;    ... = A[10];
101
102 define void @weakzerodst3(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
103 entry:
104   br label %for.body
105
106 for.body:                                         ; preds = %for.body, %entry
107   %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
108   %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
109   %conv = trunc i64 %i.02 to i32
110   %mul = shl i64 %i.02, 1
111   %arrayidx = getelementptr inbounds i32* %A, i64 %mul
112   store i32 %conv, i32* %arrayidx, align 4
113   %arrayidx1 = getelementptr inbounds i32* %A, i64 10
114   %0 = load i32* %arrayidx1, align 4
115 ; CHECK: da analyze - flow [=>p|<]!
116   %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
117   store i32 %0, i32* %B.addr.01, align 4
118   %inc = add i64 %i.02, 1
119   %cmp = icmp ult i64 %inc, 6
120   br i1 %cmp, label %for.body, label %for.end
121
122 for.end:                                          ; preds = %for.body
123   ret void
124 }
125
126
127 ;;  for (long unsigned i = 0; i < 7; i++)
128 ;;    A[2*i] = ...
129 ;;    ... = A[10];
130
131 define void @weakzerodst4(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
132 entry:
133   br label %for.body
134
135 for.body:                                         ; preds = %for.body, %entry
136   %i.02 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
137   %B.addr.01 = phi i32* [ %B, %entry ], [ %incdec.ptr, %for.body ]
138   %conv = trunc i64 %i.02 to i32
139   %mul = shl i64 %i.02, 1
140   %arrayidx = getelementptr inbounds i32* %A, i64 %mul
141   store i32 %conv, i32* %arrayidx, align 4
142   %arrayidx1 = getelementptr inbounds i32* %A, i64 10
143   %0 = load i32* %arrayidx1, align 4
144 ; CHECK: da analyze - flow [*|<]!
145   %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
146   store i32 %0, i32* %B.addr.01, align 4
147   %inc = add i64 %i.02, 1
148   %cmp = icmp ult i64 %inc, 7
149   br i1 %cmp, label %for.body, label %for.end
150
151 for.end:                                          ; preds = %for.body
152   ret void
153 }
154
155
156 ;;  for (long unsigned i = 0; i < 7; i++)
157 ;;    A[2*i] = ...
158 ;;    ... = A[-10];
159
160 define void @weakzerodst5(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
161 entry:
162   br label %for.body
163
164 for.body:                                         ; preds = %for.body, %entry
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   %mul = shl i64 %i.02, 1
169   %arrayidx = getelementptr inbounds i32* %A, i64 %mul
170   store i32 %conv, i32* %arrayidx, align 4
171   %arrayidx1 = getelementptr inbounds i32* %A, i64 -10
172   %0 = load i32* %arrayidx1, align 4
173 ; CHECK: da analyze - none!
174   %incdec.ptr = getelementptr inbounds i32* %B.addr.01, i64 1
175   store i32 %0, i32* %B.addr.01, align 4
176   %inc = add i64 %i.02, 1
177   %cmp = icmp ult i64 %inc, 7
178   br i1 %cmp, label %for.body, label %for.end
179
180 for.end:                                          ; preds = %for.body
181   ret void
182 }
183
184
185 ;;  for (long unsigned i = 0; i < n; i++)
186 ;;    A[3*i] = ...
187 ;;    ... = A[10];
188
189 define void @weakzerodst6(i32* %A, i32* %B, i64 %n) nounwind uwtable ssp {
190 entry:
191   %cmp1 = icmp eq i64 %n, 0
192   br i1 %cmp1, label %for.end, label %for.body
193
194 for.body:                                         ; preds = %for.body, %entry
195   %i.03 = phi i64 [ %inc, %for.body ], [ 0, %entry ]
196   %B.addr.02 = phi i32* [ %incdec.ptr, %for.body ], [ %B, %entry ]
197   %conv = trunc i64 %i.03 to i32
198   %mul = mul i64 %i.03, 3
199   %arrayidx = getelementptr inbounds i32* %A, i64 %mul
200   store i32 %conv, i32* %arrayidx, align 4
201   %arrayidx1 = getelementptr inbounds i32* %A, i64 10
202   %0 = load i32* %arrayidx1, align 4
203 ; CHECK: da analyze - none!
204   %incdec.ptr = getelementptr inbounds i32* %B.addr.02, i64 1
205   store i32 %0, i32* %B.addr.02, align 4
206   %inc = add i64 %i.03, 1
207   %cmp = icmp ult i64 %inc, %n
208   br i1 %cmp, label %for.body, label %for.end
209
210 for.end:                                          ; preds = %for.body, %entry
211   ret void
212 }