1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s
4 ; LSR should be able to eliminate the max computations by
5 ; making the loops use slt/ult comparisons instead of ne comparisons.
7 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
8 target triple = "i386-apple-darwin9"
10 define void @foo(ptr %r, i32 %s, i32 %w, i32 %x, ptr %j, i32 %d) nounwind {
12 ; CHECK: ## %bb.0: ## %entry
13 ; CHECK-NEXT: pushl %ebp
14 ; CHECK-NEXT: pushl %ebx
15 ; CHECK-NEXT: pushl %edi
16 ; CHECK-NEXT: pushl %esi
17 ; CHECK-NEXT: subl $28, %esp
18 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edi
19 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ebp
20 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
21 ; CHECK-NEXT: movl %edi, %ecx
22 ; CHECK-NEXT: imull %ebp, %ecx
23 ; CHECK-NEXT: cmpl $1, {{[0-9]+}}(%esp)
24 ; CHECK-NEXT: movl %ecx, (%esp) ## 4-byte Spill
25 ; CHECK-NEXT: je LBB0_19
26 ; CHECK-NEXT: ## %bb.1: ## %bb10.preheader
27 ; CHECK-NEXT: movl %ecx, %eax
28 ; CHECK-NEXT: sarl $31, %eax
29 ; CHECK-NEXT: shrl $30, %eax
30 ; CHECK-NEXT: addl %ecx, %eax
31 ; CHECK-NEXT: sarl $2, %eax
32 ; CHECK-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
33 ; CHECK-NEXT: testl %edi, %edi
34 ; CHECK-NEXT: jle LBB0_12
35 ; CHECK-NEXT: ## %bb.2: ## %bb.nph9
36 ; CHECK-NEXT: testl %ebp, %ebp
37 ; CHECK-NEXT: jle LBB0_12
38 ; CHECK-NEXT: ## %bb.3: ## %bb.nph9.split
39 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
40 ; CHECK-NEXT: incl %eax
41 ; CHECK-NEXT: xorl %ecx, %ecx
42 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
43 ; CHECK-NEXT: xorl %esi, %esi
44 ; CHECK-NEXT: .p2align 4, 0x90
45 ; CHECK-NEXT: LBB0_4: ## %bb6
46 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
47 ; CHECK-NEXT: movzbl (%eax,%esi,2), %ebx
48 ; CHECK-NEXT: movb %bl, (%edx,%esi)
49 ; CHECK-NEXT: incl %esi
50 ; CHECK-NEXT: cmpl %ebp, %esi
51 ; CHECK-NEXT: jl LBB0_4
52 ; CHECK-NEXT: ## %bb.5: ## %bb9
53 ; CHECK-NEXT: ## in Loop: Header=BB0_4 Depth=1
54 ; CHECK-NEXT: incl %ecx
55 ; CHECK-NEXT: addl {{[0-9]+}}(%esp), %eax
56 ; CHECK-NEXT: addl %ebp, %edx
57 ; CHECK-NEXT: cmpl %edi, %ecx
58 ; CHECK-NEXT: je LBB0_12
59 ; CHECK-NEXT: ## %bb.6: ## %bb7.preheader
60 ; CHECK-NEXT: ## in Loop: Header=BB0_4 Depth=1
61 ; CHECK-NEXT: xorl %esi, %esi
62 ; CHECK-NEXT: jmp LBB0_4
63 ; CHECK-NEXT: LBB0_12: ## %bb18.loopexit
64 ; CHECK-NEXT: movl (%esp), %eax ## 4-byte Reload
65 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx ## 4-byte Reload
66 ; CHECK-NEXT: addl %ecx, %eax
67 ; CHECK-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
68 ; CHECK-NEXT: cmpl $1, %edi
69 ; CHECK-NEXT: jle LBB0_13
70 ; CHECK-NEXT: ## %bb.7: ## %bb.nph5
71 ; CHECK-NEXT: cmpl $2, %ebp
72 ; CHECK-NEXT: jl LBB0_13
73 ; CHECK-NEXT: ## %bb.8: ## %bb.nph5.split
74 ; CHECK-NEXT: movl %ebp, %edx
75 ; CHECK-NEXT: shrl $31, %edx
76 ; CHECK-NEXT: addl %ebp, %edx
77 ; CHECK-NEXT: sarl %edx
78 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
79 ; CHECK-NEXT: movl %eax, %ecx
80 ; CHECK-NEXT: shrl $31, %ecx
81 ; CHECK-NEXT: addl %eax, %ecx
82 ; CHECK-NEXT: sarl %ecx
83 ; CHECK-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
84 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
85 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax ## 4-byte Reload
86 ; CHECK-NEXT: addl %ecx, %eax
87 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %esi
88 ; CHECK-NEXT: addl $2, %esi
89 ; CHECK-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
90 ; CHECK-NEXT: movl (%esp), %esi ## 4-byte Reload
91 ; CHECK-NEXT: addl %esi, %ecx
92 ; CHECK-NEXT: xorl %esi, %esi
93 ; CHECK-NEXT: xorl %edi, %edi
94 ; CHECK-NEXT: .p2align 4, 0x90
95 ; CHECK-NEXT: LBB0_9: ## %bb13
96 ; CHECK-NEXT: ## =>This Loop Header: Depth=1
97 ; CHECK-NEXT: ## Child Loop BB0_10 Depth 2
98 ; CHECK-NEXT: movl %edi, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
99 ; CHECK-NEXT: andl $1, %edi
100 ; CHECK-NEXT: movl %esi, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
101 ; CHECK-NEXT: addl %esi, %edi
102 ; CHECK-NEXT: imull {{[0-9]+}}(%esp), %edi
103 ; CHECK-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %edi ## 4-byte Folded Reload
104 ; CHECK-NEXT: xorl %esi, %esi
105 ; CHECK-NEXT: .p2align 4, 0x90
106 ; CHECK-NEXT: LBB0_10: ## %bb14
107 ; CHECK-NEXT: ## Parent Loop BB0_9 Depth=1
108 ; CHECK-NEXT: ## => This Inner Loop Header: Depth=2
109 ; CHECK-NEXT: movzbl -2(%edi,%esi,4), %ebx
110 ; CHECK-NEXT: movb %bl, (%ecx,%esi)
111 ; CHECK-NEXT: movzbl (%edi,%esi,4), %ebx
112 ; CHECK-NEXT: movb %bl, (%eax,%esi)
113 ; CHECK-NEXT: incl %esi
114 ; CHECK-NEXT: cmpl %edx, %esi
115 ; CHECK-NEXT: jl LBB0_10
116 ; CHECK-NEXT: ## %bb.11: ## %bb17
117 ; CHECK-NEXT: ## in Loop: Header=BB0_9 Depth=1
118 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edi ## 4-byte Reload
119 ; CHECK-NEXT: incl %edi
120 ; CHECK-NEXT: addl %edx, %eax
121 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %esi ## 4-byte Reload
122 ; CHECK-NEXT: addl $2, %esi
123 ; CHECK-NEXT: addl %edx, %ecx
124 ; CHECK-NEXT: cmpl {{[-0-9]+}}(%e{{[sb]}}p), %edi ## 4-byte Folded Reload
125 ; CHECK-NEXT: jl LBB0_9
126 ; CHECK-NEXT: LBB0_13: ## %bb20
127 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
128 ; CHECK-NEXT: cmpl $1, %eax
129 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edi
130 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
131 ; CHECK-NEXT: je LBB0_19
132 ; CHECK-NEXT: ## %bb.14: ## %bb20
133 ; CHECK-NEXT: cmpl $3, %eax
134 ; CHECK-NEXT: jne LBB0_24
135 ; CHECK-NEXT: ## %bb.15: ## %bb22
136 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx ## 4-byte Reload
137 ; CHECK-NEXT: addl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Folded Spill
138 ; CHECK-NEXT: testl %edi, %edi
139 ; CHECK-NEXT: jle LBB0_18
140 ; CHECK-NEXT: ## %bb.16: ## %bb.nph
141 ; CHECK-NEXT: leal 15(%edi), %eax
142 ; CHECK-NEXT: andl $-16, %eax
143 ; CHECK-NEXT: imull {{[0-9]+}}(%esp), %eax
144 ; CHECK-NEXT: addl %ebx, %ebx
145 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
146 ; CHECK-NEXT: movl (%esp), %esi ## 4-byte Reload
147 ; CHECK-NEXT: addl %esi, %ecx
148 ; CHECK-NEXT: addl %ecx, %ebx
149 ; CHECK-NEXT: addl %eax, %edx
150 ; CHECK-NEXT: leal 15(%ebp), %eax
151 ; CHECK-NEXT: andl $-16, %eax
152 ; CHECK-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
153 ; CHECK-NEXT: .p2align 4, 0x90
154 ; CHECK-NEXT: LBB0_17: ## %bb23
155 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
156 ; CHECK-NEXT: subl $4, %esp
157 ; CHECK-NEXT: pushl %ebp
158 ; CHECK-NEXT: pushl %edx
159 ; CHECK-NEXT: pushl %ebx
160 ; CHECK-NEXT: movl %ebx, %esi
161 ; CHECK-NEXT: movl %edx, %ebx
162 ; CHECK-NEXT: calll _memcpy
163 ; CHECK-NEXT: movl %ebx, %edx
164 ; CHECK-NEXT: movl %esi, %ebx
165 ; CHECK-NEXT: addl $16, %esp
166 ; CHECK-NEXT: addl %ebp, %ebx
167 ; CHECK-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %edx ## 4-byte Folded Reload
168 ; CHECK-NEXT: decl %edi
169 ; CHECK-NEXT: jne LBB0_17
170 ; CHECK-NEXT: LBB0_18: ## %bb26
171 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax ## 4-byte Reload
172 ; CHECK-NEXT: movl (%esp), %edx ## 4-byte Reload
173 ; CHECK-NEXT: addl %edx, %eax
174 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
175 ; CHECK-NEXT: addl %eax, %ecx
176 ; CHECK-NEXT: jmp LBB0_23
177 ; CHECK-NEXT: LBB0_19: ## %bb29
178 ; CHECK-NEXT: testl %edi, %edi
179 ; CHECK-NEXT: jle LBB0_22
180 ; CHECK-NEXT: ## %bb.20: ## %bb.nph11
181 ; CHECK-NEXT: movl %edi, %esi
182 ; CHECK-NEXT: leal 15(%ebp), %eax
183 ; CHECK-NEXT: andl $-16, %eax
184 ; CHECK-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
185 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edi
186 ; CHECK-NEXT: .p2align 4, 0x90
187 ; CHECK-NEXT: LBB0_21: ## %bb30
188 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
189 ; CHECK-NEXT: subl $4, %esp
190 ; CHECK-NEXT: pushl %ebp
191 ; CHECK-NEXT: pushl %edx
192 ; CHECK-NEXT: pushl %edi
193 ; CHECK-NEXT: movl %edx, %ebx
194 ; CHECK-NEXT: calll _memcpy
195 ; CHECK-NEXT: movl %ebx, %edx
196 ; CHECK-NEXT: addl $16, %esp
197 ; CHECK-NEXT: addl %ebp, %edi
198 ; CHECK-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %edx ## 4-byte Folded Reload
199 ; CHECK-NEXT: decl %esi
200 ; CHECK-NEXT: jne LBB0_21
201 ; CHECK-NEXT: LBB0_22: ## %bb33
202 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
203 ; CHECK-NEXT: movl (%esp), %edx ## 4-byte Reload
204 ; CHECK-NEXT: addl %edx, %ecx
205 ; CHECK-NEXT: LBB0_23: ## %bb33
206 ; CHECK-NEXT: movl %edx, %eax
207 ; CHECK-NEXT: shrl $31, %eax
208 ; CHECK-NEXT: addl %edx, %eax
209 ; CHECK-NEXT: sarl %eax
210 ; CHECK-NEXT: subl $4, %esp
211 ; CHECK-NEXT: pushl %eax
212 ; CHECK-NEXT: pushl $128
213 ; CHECK-NEXT: pushl %ecx
214 ; CHECK-NEXT: calll _memset
215 ; CHECK-NEXT: addl $44, %esp
216 ; CHECK-NEXT: LBB0_25: ## %return
217 ; CHECK-NEXT: popl %esi
218 ; CHECK-NEXT: popl %edi
219 ; CHECK-NEXT: popl %ebx
220 ; CHECK-NEXT: popl %ebp
222 ; CHECK-NEXT: LBB0_24: ## %return
223 ; CHECK-NEXT: addl $28, %esp
224 ; CHECK-NEXT: jmp LBB0_25
229 %.sum2 = add i32 %2, %0
230 %cond = icmp eq i32 %d, 1
231 br i1 %cond, label %bb29, label %bb10.preheader
233 bb10.preheader: ; preds = %entry
234 %3 = icmp sgt i32 %x, 0
235 br i1 %3, label %bb.nph9, label %bb18.loopexit
237 bb.nph7: ; preds = %bb7.preheader
238 %4 = mul i32 %y.08, %w
239 %5 = mul i32 %y.08, %s
241 %tmp8 = icmp sgt i32 1, %w
242 %smax9 = select i1 %tmp8, i32 1, i32 %w
245 bb6: ; preds = %bb7, %bb.nph7
246 %x.06 = phi i32 [ 0, %bb.nph7 ], [ %indvar.next7, %bb7 ]
247 %7 = add i32 %x.06, %4
248 %8 = shl i32 %x.06, 1
250 %10 = getelementptr i8, ptr %r, i32 %9
251 %11 = load i8, ptr %10, align 1
252 %12 = getelementptr i8, ptr %j, i32 %7
253 store i8 %11, ptr %12, align 1
257 %indvar.next7 = add i32 %x.06, 1
258 %exitcond10 = icmp ne i32 %indvar.next7, %smax9
259 br i1 %exitcond10, label %bb6, label %bb7.bb9_crit_edge
261 bb7.bb9_crit_edge: ; preds = %bb7
264 bb9: ; preds = %bb7.preheader, %bb7.bb9_crit_edge
268 %indvar.next11 = add i32 %y.08, 1
269 %exitcond12 = icmp ne i32 %indvar.next11, %x
270 br i1 %exitcond12, label %bb7.preheader, label %bb10.bb18.loopexit_crit_edge
272 bb10.bb18.loopexit_crit_edge: ; preds = %bb10
273 br label %bb10.bb18.loopexit_crit_edge.split
275 bb10.bb18.loopexit_crit_edge.split: ; preds = %bb.nph9, %bb10.bb18.loopexit_crit_edge
276 br label %bb18.loopexit
278 bb.nph9: ; preds = %bb10.preheader
279 %13 = icmp sgt i32 %w, 0
280 br i1 %13, label %bb.nph9.split, label %bb10.bb18.loopexit_crit_edge.split
282 bb.nph9.split: ; preds = %bb.nph9
283 br label %bb7.preheader
285 bb7.preheader: ; preds = %bb.nph9.split, %bb10
286 %y.08 = phi i32 [ 0, %bb.nph9.split ], [ %indvar.next11, %bb10 ]
287 br i1 true, label %bb.nph7, label %bb9
289 bb.nph5: ; preds = %bb18.loopexit
291 %15 = icmp slt i32 %w, 2
293 br i1 %15, label %bb18.bb20_crit_edge.split, label %bb.nph5.split
295 bb.nph5.split: ; preds = %bb.nph5
296 %tmp2 = icmp sgt i32 1, %16
297 %smax3 = select i1 %tmp2, i32 1, i32 %16
300 bb13: ; preds = %bb18, %bb.nph5.split
301 %y.14 = phi i32 [ 0, %bb.nph5.split ], [ %indvar.next1, %bb18 ]
302 %17 = mul i32 %14, %y.14
303 %18 = shl i32 %y.14, 1
304 %19 = srem i32 %y.14, 2
305 %20 = add i32 %19, %18
306 %21 = mul i32 %20, %s
307 br i1 true, label %bb.nph3, label %bb17
309 bb.nph3: ; preds = %bb13
310 %22 = add i32 %17, %0
311 %23 = add i32 %17, %.sum2
313 %tmp = icmp sgt i32 1, %24
314 %smax = select i1 %tmp, i32 1, i32 %24
317 bb14: ; preds = %bb15, %bb.nph3
318 %x.12 = phi i32 [ 0, %bb.nph3 ], [ %indvar.next, %bb15 ]
319 %25 = shl i32 %x.12, 2
320 %26 = add i32 %25, %21
321 %27 = getelementptr i8, ptr %r, i32 %26
322 %28 = load i8, ptr %27, align 1
323 %.sum = add i32 %22, %x.12
324 %29 = getelementptr i8, ptr %j, i32 %.sum
325 store i8 %28, ptr %29, align 1
326 %30 = shl i32 %x.12, 2
328 %32 = add i32 %31, %21
329 %33 = getelementptr i8, ptr %r, i32 %32
330 %34 = load i8, ptr %33, align 1
331 %.sum6 = add i32 %23, %x.12
332 %35 = getelementptr i8, ptr %j, i32 %.sum6
333 store i8 %34, ptr %35, align 1
336 bb15: ; preds = %bb14
337 %indvar.next = add i32 %x.12, 1
338 %exitcond = icmp ne i32 %indvar.next, %smax
339 br i1 %exitcond, label %bb14, label %bb15.bb17_crit_edge
341 bb15.bb17_crit_edge: ; preds = %bb15
344 bb17: ; preds = %bb15.bb17_crit_edge, %bb13
347 bb18.loopexit: ; preds = %bb10.bb18.loopexit_crit_edge.split, %bb10.preheader
348 %36 = icmp slt i32 %x, 2
349 br i1 %36, label %bb20, label %bb.nph5
351 bb18: ; preds = %bb17
352 %indvar.next1 = add i32 %y.14, 1
353 %exitcond4 = icmp ne i32 %indvar.next1, %smax3
354 br i1 %exitcond4, label %bb13, label %bb18.bb20_crit_edge
356 bb18.bb20_crit_edge: ; preds = %bb18
357 br label %bb18.bb20_crit_edge.split
359 bb18.bb20_crit_edge.split: ; preds = %bb18.bb20_crit_edge, %bb.nph5
362 bb20: ; preds = %bb18.bb20_crit_edge.split, %bb18.loopexit
363 switch i32 %d, label %return [
368 bb22: ; preds = %bb20
370 %38 = sdiv i32 %37, 4
371 %.sum3 = add i32 %38, %.sum2
373 %40 = and i32 %39, -16
375 %42 = and i32 %41, -16
376 %43 = mul i32 %40, %s
377 %44 = icmp sgt i32 %x, 0
378 br i1 %44, label %bb.nph, label %bb26
380 bb.nph: ; preds = %bb22
383 bb23: ; preds = %bb24, %bb.nph
384 %y.21 = phi i32 [ 0, %bb.nph ], [ %indvar.next5, %bb24 ]
385 %45 = mul i32 %y.21, %42
386 %.sum1 = add i32 %45, %43
387 %46 = getelementptr i8, ptr %r, i32 %.sum1
388 %47 = mul i32 %y.21, %w
389 %.sum5 = add i32 %47, %.sum3
390 %48 = getelementptr i8, ptr %j, i32 %.sum5
391 tail call void @llvm.memcpy.p0.p0.i32(ptr %48, ptr %46, i32 %w, i1 false)
394 bb24: ; preds = %bb23
395 %indvar.next5 = add i32 %y.21, 1
396 %exitcond6 = icmp ne i32 %indvar.next5, %x
397 br i1 %exitcond6, label %bb23, label %bb24.bb26_crit_edge
399 bb24.bb26_crit_edge: ; preds = %bb24
402 bb26: ; preds = %bb24.bb26_crit_edge, %bb22
404 %.sum4 = add i32 %.sum3, %49
405 %50 = getelementptr i8, ptr %j, i32 %.sum4
407 %52 = sdiv i32 %51, 2
408 tail call void @llvm.memset.p0.i32(ptr %50, i8 -128, i32 %52, i1 false)
411 bb29: ; preds = %bb20, %entry
413 %54 = and i32 %53, -16
414 %55 = icmp sgt i32 %x, 0
415 br i1 %55, label %bb.nph11, label %bb33
417 bb.nph11: ; preds = %bb29
420 bb30: ; preds = %bb31, %bb.nph11
421 %y.310 = phi i32 [ 0, %bb.nph11 ], [ %indvar.next13, %bb31 ]
422 %56 = mul i32 %y.310, %54
423 %57 = getelementptr i8, ptr %r, i32 %56
424 %58 = mul i32 %y.310, %w
425 %59 = getelementptr i8, ptr %j, i32 %58
426 tail call void @llvm.memcpy.p0.p0.i32(ptr %59, ptr %57, i32 %w, i1 false)
429 bb31: ; preds = %bb30
430 %indvar.next13 = add i32 %y.310, 1
431 %exitcond14 = icmp ne i32 %indvar.next13, %x
432 br i1 %exitcond14, label %bb30, label %bb31.bb33_crit_edge
434 bb31.bb33_crit_edge: ; preds = %bb31
437 bb33: ; preds = %bb31.bb33_crit_edge, %bb29
439 %61 = getelementptr i8, ptr %j, i32 %60
441 %63 = sdiv i32 %62, 2
442 tail call void @llvm.memset.p0.i32(ptr %61, i8 -128, i32 %63, i1 false)
445 return: ; preds = %bb20
449 define void @bar(ptr %r, i32 %s, i32 %w, i32 %x, ptr %j, i32 %d) nounwind {
451 ; CHECK: ## %bb.0: ## %entry
452 ; CHECK-NEXT: pushl %ebp
453 ; CHECK-NEXT: pushl %ebx
454 ; CHECK-NEXT: pushl %edi
455 ; CHECK-NEXT: pushl %esi
456 ; CHECK-NEXT: subl $28, %esp
457 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %esi
458 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ebp
459 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
460 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
461 ; CHECK-NEXT: movl %ebp, %edx
462 ; CHECK-NEXT: imull %eax, %edx
463 ; CHECK-NEXT: cmpl $1, {{[0-9]+}}(%esp)
464 ; CHECK-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
465 ; CHECK-NEXT: je LBB1_19
466 ; CHECK-NEXT: ## %bb.1: ## %bb10.preheader
467 ; CHECK-NEXT: movl %edx, %ecx
468 ; CHECK-NEXT: shrl $2, %ecx
469 ; CHECK-NEXT: movl %ecx, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
470 ; CHECK-NEXT: testl %ebp, %ebp
471 ; CHECK-NEXT: movl %eax, %edi
472 ; CHECK-NEXT: je LBB1_12
473 ; CHECK-NEXT: ## %bb.2: ## %bb.nph9
474 ; CHECK-NEXT: testl %eax, %eax
475 ; CHECK-NEXT: je LBB1_12
476 ; CHECK-NEXT: ## %bb.3: ## %bb.nph9.split
477 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
478 ; CHECK-NEXT: incl %eax
479 ; CHECK-NEXT: xorl %ecx, %ecx
480 ; CHECK-NEXT: movl %esi, %edx
481 ; CHECK-NEXT: xorl %esi, %esi
482 ; CHECK-NEXT: .p2align 4, 0x90
483 ; CHECK-NEXT: LBB1_4: ## %bb6
484 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
485 ; CHECK-NEXT: movzbl (%eax,%esi,2), %ebx
486 ; CHECK-NEXT: movb %bl, (%edx,%esi)
487 ; CHECK-NEXT: incl %esi
488 ; CHECK-NEXT: cmpl %edi, %esi
489 ; CHECK-NEXT: jb LBB1_4
490 ; CHECK-NEXT: ## %bb.5: ## %bb9
491 ; CHECK-NEXT: ## in Loop: Header=BB1_4 Depth=1
492 ; CHECK-NEXT: movl %edi, %ebx
493 ; CHECK-NEXT: incl %ecx
494 ; CHECK-NEXT: addl {{[0-9]+}}(%esp), %eax
495 ; CHECK-NEXT: addl %edi, %edx
496 ; CHECK-NEXT: cmpl %ebp, %ecx
497 ; CHECK-NEXT: je LBB1_12
498 ; CHECK-NEXT: ## %bb.6: ## %bb7.preheader
499 ; CHECK-NEXT: ## in Loop: Header=BB1_4 Depth=1
500 ; CHECK-NEXT: xorl %esi, %esi
501 ; CHECK-NEXT: jmp LBB1_4
502 ; CHECK-NEXT: LBB1_12: ## %bb18.loopexit
503 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax ## 4-byte Reload
504 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx ## 4-byte Reload
505 ; CHECK-NEXT: addl %ecx, %eax
506 ; CHECK-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
507 ; CHECK-NEXT: cmpl $1, %ebp
508 ; CHECK-NEXT: jbe LBB1_13
509 ; CHECK-NEXT: ## %bb.7: ## %bb.nph5
510 ; CHECK-NEXT: cmpl $2, %edi
511 ; CHECK-NEXT: jb LBB1_13
512 ; CHECK-NEXT: ## %bb.8: ## %bb.nph5.split
513 ; CHECK-NEXT: movl %edi, %ebp
514 ; CHECK-NEXT: shrl %ebp
515 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
516 ; CHECK-NEXT: shrl %eax
517 ; CHECK-NEXT: movl %eax, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
518 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %eax
519 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx ## 4-byte Reload
520 ; CHECK-NEXT: addl %eax, %ecx
521 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
522 ; CHECK-NEXT: addl $2, %edx
523 ; CHECK-NEXT: movl %edx, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
524 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edx ## 4-byte Reload
525 ; CHECK-NEXT: addl %edx, %eax
526 ; CHECK-NEXT: xorl %edx, %edx
527 ; CHECK-NEXT: xorl %ebx, %ebx
528 ; CHECK-NEXT: .p2align 4, 0x90
529 ; CHECK-NEXT: LBB1_9: ## %bb13
530 ; CHECK-NEXT: ## =>This Loop Header: Depth=1
531 ; CHECK-NEXT: ## Child Loop BB1_10 Depth 2
532 ; CHECK-NEXT: movl %ebx, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Spill
533 ; CHECK-NEXT: andl $1, %ebx
534 ; CHECK-NEXT: movl %edx, (%esp) ## 4-byte Spill
535 ; CHECK-NEXT: addl %edx, %ebx
536 ; CHECK-NEXT: imull {{[0-9]+}}(%esp), %ebx
537 ; CHECK-NEXT: addl {{[-0-9]+}}(%e{{[sb]}}p), %ebx ## 4-byte Folded Reload
538 ; CHECK-NEXT: xorl %esi, %esi
539 ; CHECK-NEXT: .p2align 4, 0x90
540 ; CHECK-NEXT: LBB1_10: ## %bb14
541 ; CHECK-NEXT: ## Parent Loop BB1_9 Depth=1
542 ; CHECK-NEXT: ## => This Inner Loop Header: Depth=2
543 ; CHECK-NEXT: movzbl -2(%ebx,%esi,4), %edx
544 ; CHECK-NEXT: movb %dl, (%eax,%esi)
545 ; CHECK-NEXT: movzbl (%ebx,%esi,4), %edx
546 ; CHECK-NEXT: movb %dl, (%ecx,%esi)
547 ; CHECK-NEXT: incl %esi
548 ; CHECK-NEXT: cmpl %ebp, %esi
549 ; CHECK-NEXT: jb LBB1_10
550 ; CHECK-NEXT: ## %bb.11: ## %bb17
551 ; CHECK-NEXT: ## in Loop: Header=BB1_9 Depth=1
552 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ebx ## 4-byte Reload
553 ; CHECK-NEXT: incl %ebx
554 ; CHECK-NEXT: addl %ebp, %ecx
555 ; CHECK-NEXT: movl (%esp), %edx ## 4-byte Reload
556 ; CHECK-NEXT: addl $2, %edx
557 ; CHECK-NEXT: addl %ebp, %eax
558 ; CHECK-NEXT: cmpl {{[-0-9]+}}(%e{{[sb]}}p), %ebx ## 4-byte Folded Reload
559 ; CHECK-NEXT: jb LBB1_9
560 ; CHECK-NEXT: LBB1_13: ## %bb20
561 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %esi
562 ; CHECK-NEXT: cmpl $1, %esi
563 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ebp
564 ; CHECK-NEXT: movl %edi, %eax
565 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
566 ; CHECK-NEXT: je LBB1_19
567 ; CHECK-NEXT: ## %bb.14: ## %bb20
568 ; CHECK-NEXT: cmpl $3, %esi
569 ; CHECK-NEXT: jne LBB1_24
570 ; CHECK-NEXT: ## %bb.15: ## %bb22
571 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %edx ## 4-byte Reload
572 ; CHECK-NEXT: addl %edx, {{[-0-9]+}}(%e{{[sb]}}p) ## 4-byte Folded Spill
573 ; CHECK-NEXT: testl %ebp, %ebp
574 ; CHECK-NEXT: je LBB1_18
575 ; CHECK-NEXT: ## %bb.16: ## %bb.nph
576 ; CHECK-NEXT: movl %ebp, %esi
577 ; CHECK-NEXT: leal 15(%ebp), %eax
578 ; CHECK-NEXT: andl $-16, %eax
579 ; CHECK-NEXT: imull {{[0-9]+}}(%esp), %eax
580 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
581 ; CHECK-NEXT: addl $15, %edx
582 ; CHECK-NEXT: andl $-16, %edx
583 ; CHECK-NEXT: movl %edx, (%esp) ## 4-byte Spill
584 ; CHECK-NEXT: addl %eax, %ecx
585 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax ## 4-byte Reload
586 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
587 ; CHECK-NEXT: leal (%edx,%eax), %ebp
588 ; CHECK-NEXT: .p2align 4, 0x90
589 ; CHECK-NEXT: LBB1_17: ## %bb23
590 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
591 ; CHECK-NEXT: subl $4, %esp
592 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ebx
593 ; CHECK-NEXT: pushl %ebx
594 ; CHECK-NEXT: pushl %ecx
595 ; CHECK-NEXT: pushl %ebp
596 ; CHECK-NEXT: movl %ecx, %edi
597 ; CHECK-NEXT: calll _memcpy
598 ; CHECK-NEXT: movl %edi, %ecx
599 ; CHECK-NEXT: addl $16, %esp
600 ; CHECK-NEXT: addl %ebx, %ebp
601 ; CHECK-NEXT: addl (%esp), %ecx ## 4-byte Folded Reload
602 ; CHECK-NEXT: decl %esi
603 ; CHECK-NEXT: jne LBB1_17
604 ; CHECK-NEXT: LBB1_18: ## %bb26
605 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax ## 4-byte Reload
606 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %ecx ## 4-byte Reload
607 ; CHECK-NEXT: addl %ecx, %eax
608 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %edx
609 ; CHECK-NEXT: addl %eax, %edx
610 ; CHECK-NEXT: shrl %ecx
611 ; CHECK-NEXT: subl $4, %esp
612 ; CHECK-NEXT: pushl %ecx
613 ; CHECK-NEXT: pushl $128
614 ; CHECK-NEXT: pushl %edx
615 ; CHECK-NEXT: jmp LBB1_23
616 ; CHECK-NEXT: LBB1_19: ## %bb29
617 ; CHECK-NEXT: testl %ebp, %ebp
618 ; CHECK-NEXT: je LBB1_22
619 ; CHECK-NEXT: ## %bb.20: ## %bb.nph11
620 ; CHECK-NEXT: movl %ebp, %esi
621 ; CHECK-NEXT: movl %eax, %edi
622 ; CHECK-NEXT: addl $15, %eax
623 ; CHECK-NEXT: andl $-16, %eax
624 ; CHECK-NEXT: movl %eax, (%esp) ## 4-byte Spill
625 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ebp
626 ; CHECK-NEXT: .p2align 4, 0x90
627 ; CHECK-NEXT: LBB1_21: ## %bb30
628 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
629 ; CHECK-NEXT: subl $4, %esp
630 ; CHECK-NEXT: pushl %edi
631 ; CHECK-NEXT: pushl %ecx
632 ; CHECK-NEXT: pushl %ebp
633 ; CHECK-NEXT: movl %ecx, %ebx
634 ; CHECK-NEXT: calll _memcpy
635 ; CHECK-NEXT: movl %ebx, %ecx
636 ; CHECK-NEXT: addl $16, %esp
637 ; CHECK-NEXT: addl %edi, %ebp
638 ; CHECK-NEXT: addl (%esp), %ecx ## 4-byte Folded Reload
639 ; CHECK-NEXT: decl %esi
640 ; CHECK-NEXT: jne LBB1_21
641 ; CHECK-NEXT: LBB1_22: ## %bb33
642 ; CHECK-NEXT: movl {{[-0-9]+}}(%e{{[sb]}}p), %eax ## 4-byte Reload
643 ; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
644 ; CHECK-NEXT: addl %eax, %ecx
645 ; CHECK-NEXT: shrl %eax
646 ; CHECK-NEXT: subl $4, %esp
647 ; CHECK-NEXT: pushl %eax
648 ; CHECK-NEXT: pushl $128
649 ; CHECK-NEXT: pushl %ecx
650 ; CHECK-NEXT: LBB1_23: ## %bb33
651 ; CHECK-NEXT: calll _memset
652 ; CHECK-NEXT: addl $44, %esp
653 ; CHECK-NEXT: LBB1_25: ## %return
654 ; CHECK-NEXT: popl %esi
655 ; CHECK-NEXT: popl %edi
656 ; CHECK-NEXT: popl %ebx
657 ; CHECK-NEXT: popl %ebp
659 ; CHECK-NEXT: LBB1_24: ## %return
660 ; CHECK-NEXT: addl $28, %esp
661 ; CHECK-NEXT: jmp LBB1_25
666 %.sum2 = add i32 %2, %0
667 %cond = icmp eq i32 %d, 1
668 br i1 %cond, label %bb29, label %bb10.preheader
670 bb10.preheader: ; preds = %entry
671 %3 = icmp ne i32 %x, 0
672 br i1 %3, label %bb.nph9, label %bb18.loopexit
674 bb.nph7: ; preds = %bb7.preheader
675 %4 = mul i32 %y.08, %w
676 %5 = mul i32 %y.08, %s
678 %tmp8 = icmp ugt i32 1, %w
679 %smax9 = select i1 %tmp8, i32 1, i32 %w
682 bb6: ; preds = %bb7, %bb.nph7
683 %x.06 = phi i32 [ 0, %bb.nph7 ], [ %indvar.next7, %bb7 ]
684 %7 = add i32 %x.06, %4
685 %8 = shl i32 %x.06, 1
687 %10 = getelementptr i8, ptr %r, i32 %9
688 %11 = load i8, ptr %10, align 1
689 %12 = getelementptr i8, ptr %j, i32 %7
690 store i8 %11, ptr %12, align 1
694 %indvar.next7 = add i32 %x.06, 1
695 %exitcond10 = icmp ne i32 %indvar.next7, %smax9
696 br i1 %exitcond10, label %bb6, label %bb7.bb9_crit_edge
698 bb7.bb9_crit_edge: ; preds = %bb7
701 bb9: ; preds = %bb7.preheader, %bb7.bb9_crit_edge
705 %indvar.next11 = add i32 %y.08, 1
706 %exitcond12 = icmp ne i32 %indvar.next11, %x
707 br i1 %exitcond12, label %bb7.preheader, label %bb10.bb18.loopexit_crit_edge
709 bb10.bb18.loopexit_crit_edge: ; preds = %bb10
710 br label %bb10.bb18.loopexit_crit_edge.split
712 bb10.bb18.loopexit_crit_edge.split: ; preds = %bb.nph9, %bb10.bb18.loopexit_crit_edge
713 br label %bb18.loopexit
715 bb.nph9: ; preds = %bb10.preheader
716 %13 = icmp ugt i32 %w, 0
717 br i1 %13, label %bb.nph9.split, label %bb10.bb18.loopexit_crit_edge.split
719 bb.nph9.split: ; preds = %bb.nph9
720 br label %bb7.preheader
722 bb7.preheader: ; preds = %bb.nph9.split, %bb10
723 %y.08 = phi i32 [ 0, %bb.nph9.split ], [ %indvar.next11, %bb10 ]
724 br i1 true, label %bb.nph7, label %bb9
726 bb.nph5: ; preds = %bb18.loopexit
728 %15 = icmp ult i32 %w, 2
730 br i1 %15, label %bb18.bb20_crit_edge.split, label %bb.nph5.split
732 bb.nph5.split: ; preds = %bb.nph5
733 %tmp2 = icmp ugt i32 1, %16
734 %smax3 = select i1 %tmp2, i32 1, i32 %16
737 bb13: ; preds = %bb18, %bb.nph5.split
738 %y.14 = phi i32 [ 0, %bb.nph5.split ], [ %indvar.next1, %bb18 ]
739 %17 = mul i32 %14, %y.14
740 %18 = shl i32 %y.14, 1
741 %19 = urem i32 %y.14, 2
742 %20 = add i32 %19, %18
743 %21 = mul i32 %20, %s
744 br i1 true, label %bb.nph3, label %bb17
746 bb.nph3: ; preds = %bb13
747 %22 = add i32 %17, %0
748 %23 = add i32 %17, %.sum2
750 %tmp = icmp ugt i32 1, %24
751 %smax = select i1 %tmp, i32 1, i32 %24
754 bb14: ; preds = %bb15, %bb.nph3
755 %x.12 = phi i32 [ 0, %bb.nph3 ], [ %indvar.next, %bb15 ]
756 %25 = shl i32 %x.12, 2
757 %26 = add i32 %25, %21
758 %27 = getelementptr i8, ptr %r, i32 %26
759 %28 = load i8, ptr %27, align 1
760 %.sum = add i32 %22, %x.12
761 %29 = getelementptr i8, ptr %j, i32 %.sum
762 store i8 %28, ptr %29, align 1
763 %30 = shl i32 %x.12, 2
765 %32 = add i32 %31, %21
766 %33 = getelementptr i8, ptr %r, i32 %32
767 %34 = load i8, ptr %33, align 1
768 %.sum6 = add i32 %23, %x.12
769 %35 = getelementptr i8, ptr %j, i32 %.sum6
770 store i8 %34, ptr %35, align 1
773 bb15: ; preds = %bb14
774 %indvar.next = add i32 %x.12, 1
775 %exitcond = icmp ne i32 %indvar.next, %smax
776 br i1 %exitcond, label %bb14, label %bb15.bb17_crit_edge
778 bb15.bb17_crit_edge: ; preds = %bb15
781 bb17: ; preds = %bb15.bb17_crit_edge, %bb13
784 bb18.loopexit: ; preds = %bb10.bb18.loopexit_crit_edge.split, %bb10.preheader
785 %36 = icmp ult i32 %x, 2
786 br i1 %36, label %bb20, label %bb.nph5
788 bb18: ; preds = %bb17
789 %indvar.next1 = add i32 %y.14, 1
790 %exitcond4 = icmp ne i32 %indvar.next1, %smax3
791 br i1 %exitcond4, label %bb13, label %bb18.bb20_crit_edge
793 bb18.bb20_crit_edge: ; preds = %bb18
794 br label %bb18.bb20_crit_edge.split
796 bb18.bb20_crit_edge.split: ; preds = %bb18.bb20_crit_edge, %bb.nph5
799 bb20: ; preds = %bb18.bb20_crit_edge.split, %bb18.loopexit
800 switch i32 %d, label %return [
805 bb22: ; preds = %bb20
807 %38 = udiv i32 %37, 4
808 %.sum3 = add i32 %38, %.sum2
810 %40 = and i32 %39, -16
812 %42 = and i32 %41, -16
813 %43 = mul i32 %40, %s
814 %44 = icmp ugt i32 %x, 0
815 br i1 %44, label %bb.nph, label %bb26
817 bb.nph: ; preds = %bb22
820 bb23: ; preds = %bb24, %bb.nph
821 %y.21 = phi i32 [ 0, %bb.nph ], [ %indvar.next5, %bb24 ]
822 %45 = mul i32 %y.21, %42
823 %.sum1 = add i32 %45, %43
824 %46 = getelementptr i8, ptr %r, i32 %.sum1
825 %47 = mul i32 %y.21, %w
826 %.sum5 = add i32 %47, %.sum3
827 %48 = getelementptr i8, ptr %j, i32 %.sum5
828 tail call void @llvm.memcpy.p0.p0.i32(ptr %48, ptr %46, i32 %w, i1 false)
831 bb24: ; preds = %bb23
832 %indvar.next5 = add i32 %y.21, 1
833 %exitcond6 = icmp ne i32 %indvar.next5, %x
834 br i1 %exitcond6, label %bb23, label %bb24.bb26_crit_edge
836 bb24.bb26_crit_edge: ; preds = %bb24
839 bb26: ; preds = %bb24.bb26_crit_edge, %bb22
841 %.sum4 = add i32 %.sum3, %49
842 %50 = getelementptr i8, ptr %j, i32 %.sum4
844 %52 = udiv i32 %51, 2
845 tail call void @llvm.memset.p0.i32(ptr %50, i8 -128, i32 %52, i1 false)
848 bb29: ; preds = %bb20, %entry
850 %54 = and i32 %53, -16
851 %55 = icmp ugt i32 %x, 0
852 br i1 %55, label %bb.nph11, label %bb33
854 bb.nph11: ; preds = %bb29
857 bb30: ; preds = %bb31, %bb.nph11
858 %y.310 = phi i32 [ 0, %bb.nph11 ], [ %indvar.next13, %bb31 ]
859 %56 = mul i32 %y.310, %54
860 %57 = getelementptr i8, ptr %r, i32 %56
861 %58 = mul i32 %y.310, %w
862 %59 = getelementptr i8, ptr %j, i32 %58
863 tail call void @llvm.memcpy.p0.p0.i32(ptr %59, ptr %57, i32 %w, i1 false)
866 bb31: ; preds = %bb30
867 %indvar.next13 = add i32 %y.310, 1
868 %exitcond14 = icmp ne i32 %indvar.next13, %x
869 br i1 %exitcond14, label %bb30, label %bb31.bb33_crit_edge
871 bb31.bb33_crit_edge: ; preds = %bb31
874 bb33: ; preds = %bb31.bb33_crit_edge, %bb29
876 %61 = getelementptr i8, ptr %j, i32 %60
878 %63 = udiv i32 %62, 2
879 tail call void @llvm.memset.p0.i32(ptr %61, i8 -128, i32 %63, i1 false)
882 return: ; preds = %bb20
886 declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1) nounwind
888 declare void @llvm.memset.p0.i32(ptr nocapture, i8, i32, i1) nounwind