1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=cmov | FileCheck %s --check-prefix=X86 --check-prefix=X86-NOSSE
3 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86 --check-prefix=X86-SSE2
5 ; This tests codegen time inlining/optimization of memcmp
8 @.str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 1
10 declare dso_local i32 @memcmp(i8*, i8*, i32)
11 declare dso_local i32 @bcmp(i8*, i8*, i32)
13 define i32 @length2(i8* %X, i8* %Y) nounwind !prof !14 {
16 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
17 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
18 ; X86-NEXT: movzwl (%ecx), %ecx
19 ; X86-NEXT: movzwl (%eax), %edx
20 ; X86-NEXT: rolw $8, %cx
21 ; X86-NEXT: rolw $8, %dx
22 ; X86-NEXT: movzwl %cx, %eax
23 ; X86-NEXT: movzwl %dx, %ecx
24 ; X86-NEXT: subl %ecx, %eax
26 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 2) nounwind
30 define i1 @length2_eq(i8* %X, i8* %Y) nounwind !prof !14 {
31 ; X86-LABEL: length2_eq:
33 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
34 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
35 ; X86-NEXT: movzwl (%ecx), %ecx
36 ; X86-NEXT: cmpw (%eax), %cx
39 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 2) nounwind
40 %c = icmp eq i32 %m, 0
44 define i1 @length2_eq_const(i8* %X) nounwind !prof !14 {
45 ; X86-LABEL: length2_eq_const:
47 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
48 ; X86-NEXT: movzwl (%eax), %eax
49 ; X86-NEXT: cmpl $12849, %eax # imm = 0x3231
52 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 1), i32 2) nounwind
53 %c = icmp ne i32 %m, 0
57 define i1 @length2_eq_nobuiltin_attr(i8* %X, i8* %Y) nounwind !prof !14 {
58 ; X86-LABEL: length2_eq_nobuiltin_attr:
61 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
62 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
63 ; X86-NEXT: calll memcmp
64 ; X86-NEXT: addl $12, %esp
65 ; X86-NEXT: testl %eax, %eax
68 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 2) nounwind nobuiltin
69 %c = icmp eq i32 %m, 0
73 define i32 @length3(i8* %X, i8* %Y) nounwind !prof !14 {
76 ; X86-NEXT: pushl %esi
77 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
78 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
79 ; X86-NEXT: movzwl (%eax), %edx
80 ; X86-NEXT: movzwl (%ecx), %esi
81 ; X86-NEXT: rolw $8, %dx
82 ; X86-NEXT: rolw $8, %si
83 ; X86-NEXT: cmpw %si, %dx
84 ; X86-NEXT: jne .LBB4_3
85 ; X86-NEXT: # %bb.1: # %loadbb1
86 ; X86-NEXT: movzbl 2(%eax), %eax
87 ; X86-NEXT: movzbl 2(%ecx), %ecx
88 ; X86-NEXT: subl %ecx, %eax
89 ; X86-NEXT: jmp .LBB4_2
90 ; X86-NEXT: .LBB4_3: # %res_block
92 ; X86-NEXT: movzbl %al, %eax
93 ; X86-NEXT: leal -1(%eax,%eax), %eax
94 ; X86-NEXT: .LBB4_2: # %endblock
97 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 3) nounwind
101 define i1 @length3_eq(i8* %X, i8* %Y) nounwind !prof !14 {
102 ; X86-LABEL: length3_eq:
104 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
105 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
106 ; X86-NEXT: movzwl (%ecx), %edx
107 ; X86-NEXT: xorw (%eax), %dx
108 ; X86-NEXT: movb 2(%ecx), %cl
109 ; X86-NEXT: xorb 2(%eax), %cl
110 ; X86-NEXT: movzbl %cl, %eax
111 ; X86-NEXT: orw %dx, %ax
112 ; X86-NEXT: setne %al
114 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 3) nounwind
115 %c = icmp ne i32 %m, 0
119 define i32 @length4(i8* %X, i8* %Y) nounwind !prof !14 {
120 ; X86-LABEL: length4:
122 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
123 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
124 ; X86-NEXT: movl (%ecx), %ecx
125 ; X86-NEXT: movl (%eax), %edx
126 ; X86-NEXT: bswapl %ecx
127 ; X86-NEXT: bswapl %edx
128 ; X86-NEXT: xorl %eax, %eax
129 ; X86-NEXT: cmpl %edx, %ecx
131 ; X86-NEXT: sbbl $0, %eax
133 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 4) nounwind
137 define i1 @length4_eq(i8* %X, i8* %Y) nounwind !prof !14 {
138 ; X86-LABEL: length4_eq:
140 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
141 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
142 ; X86-NEXT: movl (%ecx), %ecx
143 ; X86-NEXT: cmpl (%eax), %ecx
144 ; X86-NEXT: setne %al
146 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 4) nounwind
147 %c = icmp ne i32 %m, 0
151 define i1 @length4_eq_const(i8* %X) nounwind !prof !14 {
152 ; X86-LABEL: length4_eq_const:
154 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
155 ; X86-NEXT: cmpl $875770417, (%eax) # imm = 0x34333231
158 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 1), i32 4) nounwind
159 %c = icmp eq i32 %m, 0
163 define i32 @length5(i8* %X, i8* %Y) nounwind !prof !14 {
164 ; X86-LABEL: length5:
166 ; X86-NEXT: pushl %esi
167 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
168 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
169 ; X86-NEXT: movl (%eax), %edx
170 ; X86-NEXT: movl (%ecx), %esi
171 ; X86-NEXT: bswapl %edx
172 ; X86-NEXT: bswapl %esi
173 ; X86-NEXT: cmpl %esi, %edx
174 ; X86-NEXT: jne .LBB9_3
175 ; X86-NEXT: # %bb.1: # %loadbb1
176 ; X86-NEXT: movzbl 4(%eax), %eax
177 ; X86-NEXT: movzbl 4(%ecx), %ecx
178 ; X86-NEXT: subl %ecx, %eax
179 ; X86-NEXT: jmp .LBB9_2
180 ; X86-NEXT: .LBB9_3: # %res_block
181 ; X86-NEXT: setae %al
182 ; X86-NEXT: movzbl %al, %eax
183 ; X86-NEXT: leal -1(%eax,%eax), %eax
184 ; X86-NEXT: .LBB9_2: # %endblock
185 ; X86-NEXT: popl %esi
187 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 5) nounwind
191 define i1 @length5_eq(i8* %X, i8* %Y) nounwind !prof !14 {
192 ; X86-LABEL: length5_eq:
194 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
195 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
196 ; X86-NEXT: movl (%ecx), %edx
197 ; X86-NEXT: xorl (%eax), %edx
198 ; X86-NEXT: movb 4(%ecx), %cl
199 ; X86-NEXT: xorb 4(%eax), %cl
200 ; X86-NEXT: movzbl %cl, %eax
201 ; X86-NEXT: orl %edx, %eax
202 ; X86-NEXT: setne %al
204 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 5) nounwind
205 %c = icmp ne i32 %m, 0
209 define i32 @length8(i8* %X, i8* %Y) nounwind !prof !14 {
210 ; X86-LABEL: length8:
212 ; X86-NEXT: pushl %esi
213 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
214 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
215 ; X86-NEXT: movl (%esi), %ecx
216 ; X86-NEXT: movl (%eax), %edx
217 ; X86-NEXT: bswapl %ecx
218 ; X86-NEXT: bswapl %edx
219 ; X86-NEXT: cmpl %edx, %ecx
220 ; X86-NEXT: jne .LBB11_2
221 ; X86-NEXT: # %bb.1: # %loadbb1
222 ; X86-NEXT: movl 4(%esi), %ecx
223 ; X86-NEXT: movl 4(%eax), %edx
224 ; X86-NEXT: bswapl %ecx
225 ; X86-NEXT: bswapl %edx
226 ; X86-NEXT: xorl %eax, %eax
227 ; X86-NEXT: cmpl %edx, %ecx
228 ; X86-NEXT: je .LBB11_3
229 ; X86-NEXT: .LBB11_2: # %res_block
230 ; X86-NEXT: xorl %eax, %eax
231 ; X86-NEXT: cmpl %edx, %ecx
232 ; X86-NEXT: setae %al
233 ; X86-NEXT: leal -1(%eax,%eax), %eax
234 ; X86-NEXT: .LBB11_3: # %endblock
235 ; X86-NEXT: popl %esi
237 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 8) nounwind
241 define i1 @length8_eq(i8* %X, i8* %Y) nounwind !prof !14 {
242 ; X86-LABEL: length8_eq:
244 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
245 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
246 ; X86-NEXT: movl (%ecx), %edx
247 ; X86-NEXT: movl 4(%ecx), %ecx
248 ; X86-NEXT: xorl (%eax), %edx
249 ; X86-NEXT: xorl 4(%eax), %ecx
250 ; X86-NEXT: orl %edx, %ecx
253 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 8) nounwind
254 %c = icmp eq i32 %m, 0
258 define i1 @length8_eq_const(i8* %X) nounwind !prof !14 {
259 ; X86-LABEL: length8_eq_const:
261 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
262 ; X86-NEXT: movl $858927408, %ecx # imm = 0x33323130
263 ; X86-NEXT: xorl (%eax), %ecx
264 ; X86-NEXT: movl $926299444, %edx # imm = 0x37363534
265 ; X86-NEXT: xorl 4(%eax), %edx
266 ; X86-NEXT: orl %ecx, %edx
267 ; X86-NEXT: setne %al
269 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i32 8) nounwind
270 %c = icmp ne i32 %m, 0
274 define i1 @length12_eq(i8* %X, i8* %Y) nounwind !prof !14 {
275 ; X86-LABEL: length12_eq:
277 ; X86-NEXT: pushl $12
278 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
279 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
280 ; X86-NEXT: calll memcmp
281 ; X86-NEXT: addl $12, %esp
282 ; X86-NEXT: testl %eax, %eax
283 ; X86-NEXT: setne %al
285 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 12) nounwind
286 %c = icmp ne i32 %m, 0
290 define i32 @length12(i8* %X, i8* %Y) nounwind !prof !14 {
291 ; X86-LABEL: length12:
293 ; X86-NEXT: pushl $12
294 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
295 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
296 ; X86-NEXT: calll memcmp
297 ; X86-NEXT: addl $12, %esp
299 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 12) nounwind
303 ; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329
305 define i32 @length16(i8* %X, i8* %Y) nounwind !prof !14 {
306 ; X86-LABEL: length16:
308 ; X86-NEXT: pushl $16
309 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
310 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
311 ; X86-NEXT: calll memcmp
312 ; X86-NEXT: addl $12, %esp
314 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 16) nounwind
318 define i1 @length16_eq(i8* %x, i8* %y) nounwind !prof !14 {
319 ; X86-NOSSE-LABEL: length16_eq:
320 ; X86-NOSSE: # %bb.0:
321 ; X86-NOSSE-NEXT: pushl $16
322 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
323 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
324 ; X86-NOSSE-NEXT: calll memcmp
325 ; X86-NOSSE-NEXT: addl $12, %esp
326 ; X86-NOSSE-NEXT: testl %eax, %eax
327 ; X86-NOSSE-NEXT: setne %al
328 ; X86-NOSSE-NEXT: retl
330 ; X86-SSE2-LABEL: length16_eq:
332 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
333 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
334 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
335 ; X86-SSE2-NEXT: movdqu (%eax), %xmm1
336 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
337 ; X86-SSE2-NEXT: pmovmskb %xmm1, %eax
338 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
339 ; X86-SSE2-NEXT: setne %al
340 ; X86-SSE2-NEXT: retl
341 %call = tail call i32 @memcmp(i8* %x, i8* %y, i32 16) nounwind
342 %cmp = icmp ne i32 %call, 0
346 define i1 @length16_eq_const(i8* %X) nounwind !prof !14 {
347 ; X86-NOSSE-LABEL: length16_eq_const:
348 ; X86-NOSSE: # %bb.0:
349 ; X86-NOSSE-NEXT: pushl $16
350 ; X86-NOSSE-NEXT: pushl $.L.str
351 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
352 ; X86-NOSSE-NEXT: calll memcmp
353 ; X86-NOSSE-NEXT: addl $12, %esp
354 ; X86-NOSSE-NEXT: testl %eax, %eax
355 ; X86-NOSSE-NEXT: sete %al
356 ; X86-NOSSE-NEXT: retl
358 ; X86-SSE2-LABEL: length16_eq_const:
360 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
361 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
362 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
363 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
364 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
365 ; X86-SSE2-NEXT: sete %al
366 ; X86-SSE2-NEXT: retl
367 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i32 16) nounwind
368 %c = icmp eq i32 %m, 0
372 ; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914
374 define i32 @length24(i8* %X, i8* %Y) nounwind !prof !14 {
375 ; X86-LABEL: length24:
377 ; X86-NEXT: pushl $24
378 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
379 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
380 ; X86-NEXT: calll memcmp
381 ; X86-NEXT: addl $12, %esp
383 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 24) nounwind
387 define i1 @length24_eq(i8* %x, i8* %y) nounwind !prof !14 {
388 ; X86-NOSSE-LABEL: length24_eq:
389 ; X86-NOSSE: # %bb.0:
390 ; X86-NOSSE-NEXT: pushl $24
391 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
392 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
393 ; X86-NOSSE-NEXT: calll memcmp
394 ; X86-NOSSE-NEXT: addl $12, %esp
395 ; X86-NOSSE-NEXT: testl %eax, %eax
396 ; X86-NOSSE-NEXT: sete %al
397 ; X86-NOSSE-NEXT: retl
399 ; X86-SSE2-LABEL: length24_eq:
401 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
402 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
403 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
404 ; X86-SSE2-NEXT: movdqu 8(%ecx), %xmm1
405 ; X86-SSE2-NEXT: movdqu (%eax), %xmm2
406 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
407 ; X86-SSE2-NEXT: movdqu 8(%eax), %xmm0
408 ; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
409 ; X86-SSE2-NEXT: pand %xmm2, %xmm0
410 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
411 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
412 ; X86-SSE2-NEXT: sete %al
413 ; X86-SSE2-NEXT: retl
414 %call = tail call i32 @memcmp(i8* %x, i8* %y, i32 24) nounwind
415 %cmp = icmp eq i32 %call, 0
419 define i1 @length24_eq_const(i8* %X) nounwind !prof !14 {
420 ; X86-NOSSE-LABEL: length24_eq_const:
421 ; X86-NOSSE: # %bb.0:
422 ; X86-NOSSE-NEXT: pushl $24
423 ; X86-NOSSE-NEXT: pushl $.L.str
424 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
425 ; X86-NOSSE-NEXT: calll memcmp
426 ; X86-NOSSE-NEXT: addl $12, %esp
427 ; X86-NOSSE-NEXT: testl %eax, %eax
428 ; X86-NOSSE-NEXT: setne %al
429 ; X86-NOSSE-NEXT: retl
431 ; X86-SSE2-LABEL: length24_eq_const:
433 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
434 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
435 ; X86-SSE2-NEXT: movdqu 8(%eax), %xmm1
436 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
437 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
438 ; X86-SSE2-NEXT: pand %xmm1, %xmm0
439 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
440 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
441 ; X86-SSE2-NEXT: setne %al
442 ; X86-SSE2-NEXT: retl
443 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i32 24) nounwind
444 %c = icmp ne i32 %m, 0
448 define i32 @length32(i8* %X, i8* %Y) nounwind !prof !14 {
449 ; X86-LABEL: length32:
451 ; X86-NEXT: pushl $32
452 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
453 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
454 ; X86-NEXT: calll memcmp
455 ; X86-NEXT: addl $12, %esp
457 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 32) nounwind
461 ; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325
463 define i1 @length32_eq(i8* %x, i8* %y) nounwind !prof !14 {
464 ; X86-NOSSE-LABEL: length32_eq:
465 ; X86-NOSSE: # %bb.0:
466 ; X86-NOSSE-NEXT: pushl $32
467 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
468 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
469 ; X86-NOSSE-NEXT: calll memcmp
470 ; X86-NOSSE-NEXT: addl $12, %esp
471 ; X86-NOSSE-NEXT: testl %eax, %eax
472 ; X86-NOSSE-NEXT: sete %al
473 ; X86-NOSSE-NEXT: retl
475 ; X86-SSE2-LABEL: length32_eq:
477 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
478 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
479 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
480 ; X86-SSE2-NEXT: movdqu 16(%ecx), %xmm1
481 ; X86-SSE2-NEXT: movdqu (%eax), %xmm2
482 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
483 ; X86-SSE2-NEXT: movdqu 16(%eax), %xmm0
484 ; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
485 ; X86-SSE2-NEXT: pand %xmm2, %xmm0
486 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
487 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
488 ; X86-SSE2-NEXT: sete %al
489 ; X86-SSE2-NEXT: retl
490 %call = tail call i32 @memcmp(i8* %x, i8* %y, i32 32) nounwind
491 %cmp = icmp eq i32 %call, 0
495 define i1 @length32_eq_const(i8* %X) nounwind !prof !14 {
496 ; X86-NOSSE-LABEL: length32_eq_const:
497 ; X86-NOSSE: # %bb.0:
498 ; X86-NOSSE-NEXT: pushl $32
499 ; X86-NOSSE-NEXT: pushl $.L.str
500 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
501 ; X86-NOSSE-NEXT: calll memcmp
502 ; X86-NOSSE-NEXT: addl $12, %esp
503 ; X86-NOSSE-NEXT: testl %eax, %eax
504 ; X86-NOSSE-NEXT: setne %al
505 ; X86-NOSSE-NEXT: retl
507 ; X86-SSE2-LABEL: length32_eq_const:
509 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
510 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
511 ; X86-SSE2-NEXT: movdqu 16(%eax), %xmm1
512 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
513 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
514 ; X86-SSE2-NEXT: pand %xmm1, %xmm0
515 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
516 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
517 ; X86-SSE2-NEXT: setne %al
518 ; X86-SSE2-NEXT: retl
519 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i32 32) nounwind
520 %c = icmp ne i32 %m, 0
524 define i32 @length64(i8* %X, i8* %Y) nounwind !prof !14 {
525 ; X86-LABEL: length64:
527 ; X86-NEXT: pushl $64
528 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
529 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
530 ; X86-NEXT: calll memcmp
531 ; X86-NEXT: addl $12, %esp
533 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i32 64) nounwind
537 define i1 @length64_eq(i8* %x, i8* %y) nounwind !prof !14 {
538 ; X86-LABEL: length64_eq:
540 ; X86-NEXT: pushl $64
541 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
542 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
543 ; X86-NEXT: calll memcmp
544 ; X86-NEXT: addl $12, %esp
545 ; X86-NEXT: testl %eax, %eax
546 ; X86-NEXT: setne %al
548 %call = tail call i32 @memcmp(i8* %x, i8* %y, i32 64) nounwind
549 %cmp = icmp ne i32 %call, 0
553 define i1 @length64_eq_const(i8* %X) nounwind !prof !14 {
554 ; X86-LABEL: length64_eq_const:
556 ; X86-NEXT: pushl $64
557 ; X86-NEXT: pushl $.L.str
558 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
559 ; X86-NEXT: calll memcmp
560 ; X86-NEXT: addl $12, %esp
561 ; X86-NEXT: testl %eax, %eax
564 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i32 64) nounwind
565 %c = icmp eq i32 %m, 0
569 define i32 @bcmp_length2(i8* %X, i8* %Y) nounwind !prof !14 {
570 ; X86-LABEL: bcmp_length2:
572 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
573 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
574 ; X86-NEXT: movzwl (%ecx), %ecx
575 ; X86-NEXT: movzwl (%eax), %edx
576 ; X86-NEXT: rolw $8, %cx
577 ; X86-NEXT: rolw $8, %dx
578 ; X86-NEXT: movzwl %cx, %eax
579 ; X86-NEXT: movzwl %dx, %ecx
580 ; X86-NEXT: subl %ecx, %eax
582 %m = tail call i32 @bcmp(i8* %X, i8* %Y, i32 2) nounwind
586 !llvm.module.flags = !{!0}
587 !0 = !{i32 1, !"ProfileSummary", !1}
588 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
589 !2 = !{!"ProfileFormat", !"InstrProf"}
590 !3 = !{!"TotalCount", i32 10000}
591 !4 = !{!"MaxCount", i32 10}
592 !5 = !{!"MaxInternalCount", i32 1}
593 !6 = !{!"MaxFunctionCount", i32 1000}
594 !7 = !{!"NumCounts", i32 3}
595 !8 = !{!"NumFunctions", i32 3}
596 !9 = !{!"DetailedSummary", !10}
597 !10 = !{!11, !12, !13}
598 !11 = !{i32 10000, i32 100, i32 1}
599 !12 = !{i32 999000, i32 100, i32 1}
600 !13 = !{i32 999999, i32 1, i32 2}
601 !14 = !{!"function_entry_count", i32 0}