1 ; RUN: llc < %s -mtriple=thumbv6-apple-darwin10 | grep rsbs | grep "#0"
3 %struct.FILE = type { ptr, i32, i32, i16, i16, %struct.__sbuf, i32, ptr, ptr, ptr, ptr, ptr, %struct.__sbuf, ptr, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }
4 %struct.__sFILEX = type opaque
5 %struct.__sbuf = type { ptr, i32 }
6 %struct.adpcm_state = type { i16, i8 }
7 @stepsizeTable = internal constant [89 x i32] [i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 16, i32 17, i32 19, i32 21, i32 23, i32 25, i32 28, i32 31, i32 34, i32 37, i32 41, i32 45, i32 50, i32 55, i32 60, i32 66, i32 73, i32 80, i32 88, i32 97, i32 107, i32 118, i32 130, i32 143, i32 157, i32 173, i32 190, i32 209, i32 230, i32 253, i32 279, i32 307, i32 337, i32 371, i32 408, i32 449, i32 494, i32 544, i32 598, i32 658, i32 724, i32 796, i32 876, i32 963, i32 1060, i32 1166, i32 1282, i32 1411, i32 1552, i32 1707, i32 1878, i32 2066, i32 2272, i32 2499, i32 2749, i32 3024, i32 3327, i32 3660, i32 4026, i32 4428, i32 4871, i32 5358, i32 5894, i32 6484, i32 7132, i32 7845, i32 8630, i32 9493, i32 10442, i32 11487, i32 12635, i32 13899, i32 15289, i32 16818, i32 18500, i32 20350, i32 22385, i32 24623, i32 27086, i32 29794, i32 32767] ; <ptr> [#uses=4]
8 @indexTable = internal constant [16 x i32] [i32 -1, i32 -1, i32 -1, i32 -1, i32 2, i32 4, i32 6, i32 8, i32 -1, i32 -1, i32 -1, i32 -1, i32 2, i32 4, i32 6, i32 8] ; <ptr> [#uses=2]
9 @abuf = common global [500 x i8] zeroinitializer ; <ptr> [#uses=1]
10 @.str = private constant [11 x i8] c"input file\00", section "__TEXT,__cstring,cstring_literals", align 1 ; <ptr> [#uses=1]
11 @sbuf = common global [1000 x i16] zeroinitializer ; <ptr> [#uses=1]
12 @state = common global %struct.adpcm_state zeroinitializer ; <ptr> [#uses=3]
13 @__stderrp = external global ptr ; <ptr> [#uses=1]
14 @.str1 = private constant [28 x i8] c"Final valprev=%d, index=%d\0A\00", section "__TEXT,__cstring,cstring_literals", align 1 ; <ptr> [#uses=1]
16 define void @adpcm_coder(ptr nocapture %indata, ptr nocapture %outdata, i32 %len, ptr nocapture %state) nounwind {
18 %0 = getelementptr %struct.adpcm_state, ptr %state, i32 0, i32 0 ; <ptr> [#uses=2]
19 %1 = load i16, ptr %0, align 2 ; <i16> [#uses=1]
20 %2 = sext i16 %1 to i32 ; <i32> [#uses=2]
21 %3 = getelementptr %struct.adpcm_state, ptr %state, i32 0, i32 1 ; <ptr> [#uses=2]
22 %4 = load i8, ptr %3, align 2 ; <i8> [#uses=1]
23 %5 = sext i8 %4 to i32 ; <i32> [#uses=3]
24 %6 = getelementptr [89 x i32], ptr @stepsizeTable, i32 0, i32 %5 ; <ptr> [#uses=1]
25 %7 = load i32, ptr %6, align 4 ; <i32> [#uses=1]
26 %8 = icmp sgt i32 %len, 0 ; <i1> [#uses=1]
27 br i1 %8, label %bb, label %bb27
29 bb: ; preds = %bb25, %entry
30 %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb25 ] ; <i32> [#uses=2]
31 %outp.136 = phi ptr [ %outdata, %entry ], [ %outp.0, %bb25 ] ; <ptr> [#uses=3]
32 %bufferstep.035 = phi i32 [ 1, %entry ], [ %tmp, %bb25 ] ; <i32> [#uses=3]
33 %outputbuffer.134 = phi i32 [ undef, %entry ], [ %outputbuffer.0, %bb25 ] ; <i32> [#uses=2]
34 %index.033 = phi i32 [ %5, %entry ], [ %index.2, %bb25 ] ; <i32> [#uses=1]
35 %valpred.132 = phi i32 [ %2, %entry ], [ %valpred.2, %bb25 ] ; <i32> [#uses=2]
36 %step.031 = phi i32 [ %7, %entry ], [ %36, %bb25 ] ; <i32> [#uses=5]
37 %inp.038 = getelementptr i16, ptr %indata, i32 %indvar ; <ptr> [#uses=1]
38 %9 = load i16, ptr %inp.038, align 2 ; <i16> [#uses=1]
39 %10 = sext i16 %9 to i32 ; <i32> [#uses=1]
40 %11 = sub i32 %10, %valpred.132 ; <i32> [#uses=3]
41 %12 = icmp slt i32 %11, 0 ; <i1> [#uses=1]
42 %iftmp.1.0 = select i1 %12, i32 8, i32 0 ; <i32> [#uses=2]
43 %13 = sub i32 0, %11 ; <i32> [#uses=1]
44 %14 = icmp eq i32 %iftmp.1.0, 0 ; <i1> [#uses=2]
45 %. = select i1 %14, i32 %11, i32 %13 ; <i32> [#uses=2]
46 %15 = ashr i32 %step.031, 3 ; <i32> [#uses=1]
47 %16 = icmp slt i32 %., %step.031 ; <i1> [#uses=2]
48 %delta.0 = select i1 %16, i32 0, i32 4 ; <i32> [#uses=2]
49 %17 = select i1 %16, i32 0, i32 %step.031 ; <i32> [#uses=2]
50 %diff.1 = sub i32 %., %17 ; <i32> [#uses=2]
51 %18 = ashr i32 %step.031, 1 ; <i32> [#uses=2]
52 %19 = icmp slt i32 %diff.1, %18 ; <i1> [#uses=2]
53 %20 = or i32 %delta.0, 2 ; <i32> [#uses=1]
54 %21 = select i1 %19, i32 %delta.0, i32 %20 ; <i32> [#uses=1]
55 %22 = select i1 %19, i32 0, i32 %18 ; <i32> [#uses=2]
56 %diff.2 = sub i32 %diff.1, %22 ; <i32> [#uses=1]
57 %23 = ashr i32 %step.031, 2 ; <i32> [#uses=2]
58 %24 = icmp slt i32 %diff.2, %23 ; <i1> [#uses=2]
59 %25 = zext i1 %24 to i32 ; <i32> [#uses=1]
60 %26 = select i1 %24, i32 0, i32 %23 ; <i32> [#uses=1]
61 %vpdiff.0 = add i32 %17, %15 ; <i32> [#uses=1]
62 %vpdiff.1 = add i32 %vpdiff.0, %22 ; <i32> [#uses=1]
63 %vpdiff.2 = add i32 %vpdiff.1, %26 ; <i32> [#uses=2]
64 %tmp30 = sub i32 0, %vpdiff.2 ; <i32> [#uses=1]
65 %valpred.0.p = select i1 %14, i32 %vpdiff.2, i32 %tmp30 ; <i32> [#uses=1]
66 %valpred.0 = add i32 %valpred.0.p, %valpred.132 ; <i32> [#uses=3]
67 %27 = icmp sgt i32 %valpred.0, 32767 ; <i1> [#uses=1]
68 br i1 %27, label %bb18, label %bb16
71 %28 = icmp slt i32 %valpred.0, -32768 ; <i1> [#uses=1]
72 br i1 %28, label %bb17, label %bb18
77 bb18: ; preds = %bb17, %bb16, %bb
78 %valpred.2 = phi i32 [ -32768, %bb17 ], [ 32767, %bb ], [ %valpred.0, %bb16 ] ; <i32> [#uses=2]
79 %delta.1 = or i32 %21, %iftmp.1.0 ; <i32> [#uses=1]
80 %delta.2 = or i32 %delta.1, %25 ; <i32> [#uses=1]
81 %29 = xor i32 %delta.2, 1 ; <i32> [#uses=3]
82 %30 = getelementptr [16 x i32], ptr @indexTable, i32 0, i32 %29 ; <ptr> [#uses=1]
83 %31 = load i32, ptr %30, align 4 ; <i32> [#uses=1]
84 %32 = add i32 %31, %index.033 ; <i32> [#uses=2]
85 %33 = icmp slt i32 %32, 0 ; <i1> [#uses=1]
86 %index.1 = select i1 %33, i32 0, i32 %32 ; <i32> [#uses=2]
87 %34 = icmp sgt i32 %index.1, 88 ; <i1> [#uses=1]
88 %index.2 = select i1 %34, i32 88, i32 %index.1 ; <i32> [#uses=3]
89 %35 = getelementptr [89 x i32], ptr @stepsizeTable, i32 0, i32 %index.2 ; <ptr> [#uses=1]
90 %36 = load i32, ptr %35, align 4 ; <i32> [#uses=1]
91 %37 = icmp eq i32 %bufferstep.035, 0 ; <i1> [#uses=1]
92 br i1 %37, label %bb24, label %bb23
95 %38 = shl i32 %29, 4 ; <i32> [#uses=1]
96 %39 = and i32 %38, 240 ; <i32> [#uses=1]
100 %40 = trunc i32 %29 to i8 ; <i8> [#uses=1]
101 %41 = and i8 %40, 15 ; <i8> [#uses=1]
102 %42 = trunc i32 %outputbuffer.134 to i8 ; <i8> [#uses=1]
103 %43 = or i8 %41, %42 ; <i8> [#uses=1]
104 store i8 %43, ptr %outp.136, align 1
105 %44 = getelementptr i8, ptr %outp.136, i32 1 ; <ptr> [#uses=1]
108 bb25: ; preds = %bb24, %bb23
109 %outputbuffer.0 = phi i32 [ %39, %bb23 ], [ %outputbuffer.134, %bb24 ] ; <i32> [#uses=2]
110 %outp.0 = phi ptr [ %outp.136, %bb23 ], [ %44, %bb24 ] ; <ptr> [#uses=2]
111 %tmp = xor i32 %bufferstep.035, 1 ; <i32> [#uses=1]
112 %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2]
113 %exitcond = icmp eq i32 %indvar.next, %len ; <i1> [#uses=1]
114 br i1 %exitcond, label %bb26.bb27_crit_edge, label %bb
116 bb26.bb27_crit_edge: ; preds = %bb25
117 %phitmp44 = icmp eq i32 %bufferstep.035, 1 ; <i1> [#uses=1]
120 bb27: ; preds = %bb26.bb27_crit_edge, %entry
121 %outp.1.lcssa = phi ptr [ %outp.0, %bb26.bb27_crit_edge ], [ %outdata, %entry ] ; <ptr> [#uses=1]
122 %bufferstep.0.lcssa = phi i1 [ %phitmp44, %bb26.bb27_crit_edge ], [ false, %entry ] ; <i1> [#uses=1]
123 %outputbuffer.1.lcssa = phi i32 [ %outputbuffer.0, %bb26.bb27_crit_edge ], [ undef, %entry ] ; <i32> [#uses=1]
124 %index.0.lcssa = phi i32 [ %index.2, %bb26.bb27_crit_edge ], [ %5, %entry ] ; <i32> [#uses=1]
125 %valpred.1.lcssa = phi i32 [ %valpred.2, %bb26.bb27_crit_edge ], [ %2, %entry ] ; <i32> [#uses=1]
126 br i1 %bufferstep.0.lcssa, label %bb28, label %bb29
128 bb28: ; preds = %bb27
129 %45 = trunc i32 %outputbuffer.1.lcssa to i8 ; <i8> [#uses=1]
130 store i8 %45, ptr %outp.1.lcssa, align 1
133 bb29: ; preds = %bb28, %bb27
134 %46 = trunc i32 %valpred.1.lcssa to i16 ; <i16> [#uses=1]
135 store i16 %46, ptr %0, align 2
136 %47 = trunc i32 %index.0.lcssa to i8 ; <i8> [#uses=1]
137 store i8 %47, ptr %3, align 2
141 define void @adpcm_decoder(ptr nocapture %indata, ptr nocapture %outdata, i32 %len, ptr nocapture %state) nounwind {
143 %0 = getelementptr %struct.adpcm_state, ptr %state, i32 0, i32 0 ; <ptr> [#uses=2]
144 %1 = load i16, ptr %0, align 2 ; <i16> [#uses=1]
145 %2 = sext i16 %1 to i32 ; <i32> [#uses=2]
146 %3 = getelementptr %struct.adpcm_state, ptr %state, i32 0, i32 1 ; <ptr> [#uses=2]
147 %4 = load i8, ptr %3, align 2 ; <i8> [#uses=1]
148 %5 = sext i8 %4 to i32 ; <i32> [#uses=3]
149 %6 = getelementptr [89 x i32], ptr @stepsizeTable, i32 0, i32 %5 ; <ptr> [#uses=1]
150 %7 = load i32, ptr %6, align 4 ; <i32> [#uses=1]
151 %8 = icmp sgt i32 %len, 0 ; <i1> [#uses=1]
152 br i1 %8, label %bb, label %bb22
154 bb: ; preds = %bb20, %entry
155 %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb20 ] ; <i32> [#uses=2]
156 %inp.131 = phi ptr [ %indata, %entry ], [ %inp.0, %bb20 ] ; <ptr> [#uses=3]
157 %bufferstep.028 = phi i32 [ 0, %entry ], [ %tmp, %bb20 ] ; <i32> [#uses=2]
158 %inputbuffer.127 = phi i32 [ undef, %entry ], [ %inputbuffer.0, %bb20 ] ; <i32> [#uses=2]
159 %index.026 = phi i32 [ %5, %entry ], [ %index.2, %bb20 ] ; <i32> [#uses=1]
160 %valpred.125 = phi i32 [ %2, %entry ], [ %valpred.2, %bb20 ] ; <i32> [#uses=1]
161 %step.024 = phi i32 [ %7, %entry ], [ %35, %bb20 ] ; <i32> [#uses=4]
162 %outp.030 = getelementptr i16, ptr %outdata, i32 %indvar ; <ptr> [#uses=1]
163 %9 = icmp eq i32 %bufferstep.028, 0 ; <i1> [#uses=1]
164 br i1 %9, label %bb2, label %bb3
167 %10 = load i8, ptr %inp.131, align 1 ; <i8> [#uses=1]
168 %11 = sext i8 %10 to i32 ; <i32> [#uses=2]
169 %12 = getelementptr i8, ptr %inp.131, i32 1 ; <ptr> [#uses=1]
170 %13 = ashr i32 %11, 4 ; <i32> [#uses=1]
173 bb3: ; preds = %bb2, %bb
174 %inputbuffer.0 = phi i32 [ %11, %bb2 ], [ %inputbuffer.127, %bb ] ; <i32> [#uses=1]
175 %delta.0.in = phi i32 [ %13, %bb2 ], [ %inputbuffer.127, %bb ] ; <i32> [#uses=5]
176 %inp.0 = phi ptr [ %12, %bb2 ], [ %inp.131, %bb ] ; <ptr> [#uses=1]
177 %delta.0 = and i32 %delta.0.in, 15 ; <i32> [#uses=1]
178 %tmp = xor i32 %bufferstep.028, 1 ; <i32> [#uses=1]
179 %14 = getelementptr [16 x i32], ptr @indexTable, i32 0, i32 %delta.0 ; <ptr> [#uses=1]
180 %15 = load i32, ptr %14, align 4 ; <i32> [#uses=1]
181 %16 = add i32 %15, %index.026 ; <i32> [#uses=2]
182 %17 = icmp slt i32 %16, 0 ; <i1> [#uses=1]
183 %index.1 = select i1 %17, i32 0, i32 %16 ; <i32> [#uses=2]
184 %18 = icmp sgt i32 %index.1, 88 ; <i1> [#uses=1]
185 %index.2 = select i1 %18, i32 88, i32 %index.1 ; <i32> [#uses=3]
186 %19 = and i32 %delta.0.in, 8 ; <i32> [#uses=1]
187 %20 = ashr i32 %step.024, 3 ; <i32> [#uses=1]
188 %21 = and i32 %delta.0.in, 4 ; <i32> [#uses=1]
189 %22 = icmp eq i32 %21, 0 ; <i1> [#uses=1]
190 %23 = select i1 %22, i32 0, i32 %step.024 ; <i32> [#uses=1]
191 %vpdiff.0 = add i32 %23, %20 ; <i32> [#uses=2]
192 %24 = and i32 %delta.0.in, 2 ; <i32> [#uses=1]
193 %25 = icmp eq i32 %24, 0 ; <i1> [#uses=1]
194 br i1 %25, label %bb11, label %bb10
197 %26 = ashr i32 %step.024, 1 ; <i32> [#uses=1]
198 %27 = add i32 %vpdiff.0, %26 ; <i32> [#uses=1]
201 bb11: ; preds = %bb10, %bb3
202 %vpdiff.1 = phi i32 [ %27, %bb10 ], [ %vpdiff.0, %bb3 ] ; <i32> [#uses=2]
203 %28 = and i32 %delta.0.in, 1 ; <i32> [#uses=1]
204 %toBool = icmp eq i32 %28, 0 ; <i1> [#uses=1]
205 br i1 %toBool, label %bb13, label %bb12
207 bb12: ; preds = %bb11
208 %29 = ashr i32 %step.024, 2 ; <i32> [#uses=1]
209 %30 = add i32 %vpdiff.1, %29 ; <i32> [#uses=1]
212 bb13: ; preds = %bb12, %bb11
213 %vpdiff.2 = phi i32 [ %30, %bb12 ], [ %vpdiff.1, %bb11 ] ; <i32> [#uses=2]
214 %31 = icmp eq i32 %19, 0 ; <i1> [#uses=1]
215 %tmp23 = sub i32 0, %vpdiff.2 ; <i32> [#uses=1]
216 %valpred.0.p = select i1 %31, i32 %vpdiff.2, i32 %tmp23 ; <i32> [#uses=1]
217 %valpred.0 = add i32 %valpred.0.p, %valpred.125 ; <i32> [#uses=3]
218 %32 = icmp sgt i32 %valpred.0, 32767 ; <i1> [#uses=1]
219 br i1 %32, label %bb20, label %bb18
221 bb18: ; preds = %bb13
222 %33 = icmp slt i32 %valpred.0, -32768 ; <i1> [#uses=1]
223 br i1 %33, label %bb19, label %bb20
225 bb19: ; preds = %bb18
228 bb20: ; preds = %bb19, %bb18, %bb13
229 %valpred.2 = phi i32 [ -32768, %bb19 ], [ 32767, %bb13 ], [ %valpred.0, %bb18 ] ; <i32> [#uses=3]
230 %34 = getelementptr [89 x i32], ptr @stepsizeTable, i32 0, i32 %index.2 ; <ptr> [#uses=1]
231 %35 = load i32, ptr %34, align 4 ; <i32> [#uses=1]
232 %36 = trunc i32 %valpred.2 to i16 ; <i16> [#uses=1]
233 store i16 %36, ptr %outp.030, align 2
234 %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2]
235 %exitcond = icmp eq i32 %indvar.next, %len ; <i1> [#uses=1]
236 br i1 %exitcond, label %bb22, label %bb
238 bb22: ; preds = %bb20, %entry
239 %index.0.lcssa = phi i32 [ %5, %entry ], [ %index.2, %bb20 ] ; <i32> [#uses=1]
240 %valpred.1.lcssa = phi i32 [ %2, %entry ], [ %valpred.2, %bb20 ] ; <i32> [#uses=1]
241 %37 = trunc i32 %valpred.1.lcssa to i16 ; <i16> [#uses=1]
242 store i16 %37, ptr %0, align 2
243 %38 = trunc i32 %index.0.lcssa to i8 ; <i8> [#uses=1]
244 store i8 %38, ptr %3, align 2
248 define i32 @main() nounwind {
252 bb: ; preds = %bb3, %entry
253 %0 = tail call i32 (...) @read(i32 0, ptr @abuf, i32 500) nounwind ; <i32> [#uses=4]
254 %1 = icmp slt i32 %0, 0 ; <i1> [#uses=1]
255 br i1 %1, label %bb1, label %bb2
258 tail call void @perror(ptr @.str) nounwind
262 %2 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
263 br i1 %2, label %bb4, label %bb3
266 %3 = shl i32 %0, 1 ; <i32> [#uses=1]
267 tail call void @adpcm_decoder(ptr @abuf, ptr @sbuf, i32 %3, ptr @state) nounwind
268 %4 = shl i32 %0, 2 ; <i32> [#uses=1]
269 %5 = tail call i32 (...) @write(i32 1, ptr @sbuf, i32 %4) nounwind ; <i32> [#uses=0]
273 %6 = load ptr, ptr @__stderrp, align 4 ; <ptr> [#uses=1]
274 %7 = load i16, ptr @state, align 4 ; <i16> [#uses=1]
275 %8 = sext i16 %7 to i32 ; <i32> [#uses=1]
276 %9 = load i8, ptr getelementptr (%struct.adpcm_state, ptr @state, i32 0, i32 1), align 2 ; <i8> [#uses=1]
277 %10 = sext i8 %9 to i32 ; <i32> [#uses=1]
278 %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr %6, ptr @.str1, i32 %8, i32 %10) nounwind ; <i32> [#uses=0]
282 declare i32 @read(...)
284 declare void @perror(ptr nocapture) nounwind
286 declare i32 @write(...)
288 declare i32 @fprintf(ptr nocapture, ptr nocapture, ...) nounwind