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
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64 --check-prefix=X64-SSE2
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s --check-prefix=X64 --check-prefix=X64-AVX --check-prefix=X64-AVX1
6 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx2 | FileCheck %s --check-prefix=X64 --check-prefix=X64-AVX --check-prefix=X64-AVX2
8 ; This tests codegen time inlining/optimization of memcmp
11 @.str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 1
13 declare i32 @memcmp(i8*, i8*, i64)
15 define i32 @length2(i8* %X, i8* %Y) nounwind minsize {
20 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
21 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
22 ; X86-NEXT: calll memcmp
23 ; X86-NEXT: addl $16, %esp
30 ; X64-NEXT: jmp memcmp # TAILCALL
31 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind
35 define i1 @length2_eq(i8* %X, i8* %Y) nounwind minsize {
36 ; X86-LABEL: length2_eq:
38 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
39 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
40 ; X86-NEXT: movzwl (%ecx), %ecx
41 ; X86-NEXT: cmpw (%eax), %cx
45 ; X64-LABEL: length2_eq:
47 ; X64-NEXT: movzwl (%rdi), %eax
48 ; X64-NEXT: cmpw (%rsi), %ax
51 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind
52 %c = icmp eq i32 %m, 0
56 define i1 @length2_eq_const(i8* %X) nounwind minsize {
57 ; X86-LABEL: length2_eq_const:
59 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
60 ; X86-NEXT: cmpw $12849, (%eax) # imm = 0x3231
64 ; X64-LABEL: length2_eq_const:
66 ; X64-NEXT: cmpw $12849, (%rdi) # imm = 0x3231
69 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 1), i64 2) nounwind
70 %c = icmp ne i32 %m, 0
74 define i1 @length2_eq_nobuiltin_attr(i8* %X, i8* %Y) nounwind minsize {
75 ; X86-LABEL: length2_eq_nobuiltin_attr:
79 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
80 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
81 ; X86-NEXT: calll memcmp
82 ; X86-NEXT: addl $16, %esp
83 ; X86-NEXT: testl %eax, %eax
87 ; X64-LABEL: length2_eq_nobuiltin_attr:
89 ; X64-NEXT: pushq %rax
92 ; X64-NEXT: callq memcmp
93 ; X64-NEXT: testl %eax, %eax
97 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind nobuiltin
98 %c = icmp eq i32 %m, 0
102 define i32 @length3(i8* %X, i8* %Y) nounwind minsize {
103 ; X86-LABEL: length3:
107 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
108 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
109 ; X86-NEXT: calll memcmp
110 ; X86-NEXT: addl $16, %esp
113 ; X64-LABEL: length3:
116 ; X64-NEXT: popq %rdx
117 ; X64-NEXT: jmp memcmp # TAILCALL
118 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 3) nounwind
122 define i1 @length3_eq(i8* %X, i8* %Y) nounwind minsize {
123 ; X86-LABEL: length3_eq:
127 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
128 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
129 ; X86-NEXT: calll memcmp
130 ; X86-NEXT: addl $16, %esp
131 ; X86-NEXT: testl %eax, %eax
132 ; X86-NEXT: setne %al
135 ; X64-LABEL: length3_eq:
137 ; X64-NEXT: pushq %rax
139 ; X64-NEXT: popq %rdx
140 ; X64-NEXT: callq memcmp
141 ; X64-NEXT: testl %eax, %eax
142 ; X64-NEXT: setne %al
143 ; X64-NEXT: popq %rcx
145 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 3) nounwind
146 %c = icmp ne i32 %m, 0
150 define i32 @length4(i8* %X, i8* %Y) nounwind minsize {
151 ; X86-LABEL: length4:
155 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
156 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
157 ; X86-NEXT: calll memcmp
158 ; X86-NEXT: addl $16, %esp
161 ; X64-LABEL: length4:
164 ; X64-NEXT: popq %rdx
165 ; X64-NEXT: jmp memcmp # TAILCALL
166 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind
170 define i1 @length4_eq(i8* %X, i8* %Y) nounwind minsize {
171 ; X86-LABEL: length4_eq:
173 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
174 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
175 ; X86-NEXT: movl (%ecx), %ecx
176 ; X86-NEXT: cmpl (%eax), %ecx
177 ; X86-NEXT: setne %al
180 ; X64-LABEL: length4_eq:
182 ; X64-NEXT: movl (%rdi), %eax
183 ; X64-NEXT: cmpl (%rsi), %eax
184 ; X64-NEXT: setne %al
186 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind
187 %c = icmp ne i32 %m, 0
191 define i1 @length4_eq_const(i8* %X) nounwind minsize {
192 ; X86-LABEL: length4_eq_const:
194 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
195 ; X86-NEXT: cmpl $875770417, (%eax) # imm = 0x34333231
199 ; X64-LABEL: length4_eq_const:
201 ; X64-NEXT: cmpl $875770417, (%rdi) # imm = 0x34333231
204 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 1), i64 4) nounwind
205 %c = icmp eq i32 %m, 0
209 define i32 @length5(i8* %X, i8* %Y) nounwind minsize {
210 ; X86-LABEL: length5:
214 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
215 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
216 ; X86-NEXT: calll memcmp
217 ; X86-NEXT: addl $16, %esp
220 ; X64-LABEL: length5:
223 ; X64-NEXT: popq %rdx
224 ; X64-NEXT: jmp memcmp # TAILCALL
225 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 5) nounwind
229 define i1 @length5_eq(i8* %X, i8* %Y) nounwind minsize {
230 ; X86-LABEL: length5_eq:
234 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
235 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
236 ; X86-NEXT: calll memcmp
237 ; X86-NEXT: addl $16, %esp
238 ; X86-NEXT: testl %eax, %eax
239 ; X86-NEXT: setne %al
242 ; X64-LABEL: length5_eq:
244 ; X64-NEXT: pushq %rax
246 ; X64-NEXT: popq %rdx
247 ; X64-NEXT: callq memcmp
248 ; X64-NEXT: testl %eax, %eax
249 ; X64-NEXT: setne %al
250 ; X64-NEXT: popq %rcx
252 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 5) nounwind
253 %c = icmp ne i32 %m, 0
257 define i32 @length8(i8* %X, i8* %Y) nounwind minsize {
258 ; X86-LABEL: length8:
262 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
263 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
264 ; X86-NEXT: calll memcmp
265 ; X86-NEXT: addl $16, %esp
268 ; X64-LABEL: length8:
271 ; X64-NEXT: popq %rdx
272 ; X64-NEXT: jmp memcmp # TAILCALL
273 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 8) nounwind
277 define i1 @length8_eq(i8* %X, i8* %Y) nounwind minsize {
278 ; X86-LABEL: length8_eq:
282 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
283 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
284 ; X86-NEXT: calll memcmp
285 ; X86-NEXT: addl $16, %esp
286 ; X86-NEXT: testl %eax, %eax
290 ; X64-LABEL: length8_eq:
292 ; X64-NEXT: movq (%rdi), %rax
293 ; X64-NEXT: cmpq (%rsi), %rax
296 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 8) nounwind
297 %c = icmp eq i32 %m, 0
301 define i1 @length8_eq_const(i8* %X) nounwind minsize {
302 ; X86-LABEL: length8_eq_const:
306 ; X86-NEXT: pushl $.L.str
307 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
308 ; X86-NEXT: calll memcmp
309 ; X86-NEXT: addl $16, %esp
310 ; X86-NEXT: testl %eax, %eax
311 ; X86-NEXT: setne %al
314 ; X64-LABEL: length8_eq_const:
316 ; X64-NEXT: movabsq $3978425819141910832, %rax # imm = 0x3736353433323130
317 ; X64-NEXT: cmpq %rax, (%rdi)
318 ; X64-NEXT: setne %al
320 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 8) nounwind
321 %c = icmp ne i32 %m, 0
325 define i1 @length12_eq(i8* %X, i8* %Y) nounwind minsize {
326 ; X86-LABEL: length12_eq:
329 ; X86-NEXT: pushl $12
330 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
331 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
332 ; X86-NEXT: calll memcmp
333 ; X86-NEXT: addl $16, %esp
334 ; X86-NEXT: testl %eax, %eax
335 ; X86-NEXT: setne %al
338 ; X64-LABEL: length12_eq:
340 ; X64-NEXT: pushq %rax
341 ; X64-NEXT: pushq $12
342 ; X64-NEXT: popq %rdx
343 ; X64-NEXT: callq memcmp
344 ; X64-NEXT: testl %eax, %eax
345 ; X64-NEXT: setne %al
346 ; X64-NEXT: popq %rcx
348 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 12) nounwind
349 %c = icmp ne i32 %m, 0
353 define i32 @length12(i8* %X, i8* %Y) nounwind minsize {
354 ; X86-LABEL: length12:
357 ; X86-NEXT: pushl $12
358 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
359 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
360 ; X86-NEXT: calll memcmp
361 ; X86-NEXT: addl $16, %esp
364 ; X64-LABEL: length12:
366 ; X64-NEXT: pushq $12
367 ; X64-NEXT: popq %rdx
368 ; X64-NEXT: jmp memcmp # TAILCALL
369 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 12) nounwind
373 ; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329
375 define i32 @length16(i8* %X, i8* %Y) nounwind minsize {
376 ; X86-LABEL: length16:
379 ; X86-NEXT: pushl $16
380 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
381 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
382 ; X86-NEXT: calll memcmp
383 ; X86-NEXT: addl $16, %esp
386 ; X64-LABEL: length16:
388 ; X64-NEXT: pushq $16
389 ; X64-NEXT: popq %rdx
390 ; X64-NEXT: jmp memcmp # TAILCALL
391 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 16) nounwind
395 define i1 @length16_eq(i8* %x, i8* %y) nounwind minsize {
396 ; X86-NOSSE-LABEL: length16_eq:
397 ; X86-NOSSE: # %bb.0:
398 ; X86-NOSSE-NEXT: pushl $0
399 ; X86-NOSSE-NEXT: pushl $16
400 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
401 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
402 ; X86-NOSSE-NEXT: calll memcmp
403 ; X86-NOSSE-NEXT: addl $16, %esp
404 ; X86-NOSSE-NEXT: testl %eax, %eax
405 ; X86-NOSSE-NEXT: setne %al
406 ; X86-NOSSE-NEXT: retl
408 ; X86-SSE2-LABEL: length16_eq:
410 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
411 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
412 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
413 ; X86-SSE2-NEXT: movdqu (%eax), %xmm1
414 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
415 ; X86-SSE2-NEXT: pmovmskb %xmm1, %eax
416 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
417 ; X86-SSE2-NEXT: setne %al
418 ; X86-SSE2-NEXT: retl
420 ; X64-SSE2-LABEL: length16_eq:
422 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm0
423 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm1
424 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
425 ; X64-SSE2-NEXT: pmovmskb %xmm1, %eax
426 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
427 ; X64-SSE2-NEXT: setne %al
428 ; X64-SSE2-NEXT: retq
430 ; X64-AVX-LABEL: length16_eq:
432 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
433 ; X64-AVX-NEXT: vpxor (%rsi), %xmm0, %xmm0
434 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
435 ; X64-AVX-NEXT: setne %al
437 %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 16) nounwind
438 %cmp = icmp ne i32 %call, 0
442 define i1 @length16_eq_const(i8* %X) nounwind minsize {
443 ; X86-NOSSE-LABEL: length16_eq_const:
444 ; X86-NOSSE: # %bb.0:
445 ; X86-NOSSE-NEXT: pushl $0
446 ; X86-NOSSE-NEXT: pushl $16
447 ; X86-NOSSE-NEXT: pushl $.L.str
448 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
449 ; X86-NOSSE-NEXT: calll memcmp
450 ; X86-NOSSE-NEXT: addl $16, %esp
451 ; X86-NOSSE-NEXT: testl %eax, %eax
452 ; X86-NOSSE-NEXT: sete %al
453 ; X86-NOSSE-NEXT: retl
455 ; X86-SSE2-LABEL: length16_eq_const:
457 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
458 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
459 ; X86-SSE2-NEXT: pcmpeqb {{\.LCPI.*}}, %xmm0
460 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
461 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
462 ; X86-SSE2-NEXT: sete %al
463 ; X86-SSE2-NEXT: retl
465 ; X64-SSE2-LABEL: length16_eq_const:
467 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
468 ; X64-SSE2-NEXT: pcmpeqb {{.*}}(%rip), %xmm0
469 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
470 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
471 ; X64-SSE2-NEXT: sete %al
472 ; X64-SSE2-NEXT: retq
474 ; X64-AVX-LABEL: length16_eq_const:
476 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
477 ; X64-AVX-NEXT: vpxor {{.*}}(%rip), %xmm0, %xmm0
478 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
479 ; X64-AVX-NEXT: sete %al
481 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 16) nounwind
482 %c = icmp eq i32 %m, 0
486 ; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914
488 define i32 @length24(i8* %X, i8* %Y) nounwind minsize {
489 ; X86-LABEL: length24:
492 ; X86-NEXT: pushl $24
493 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
494 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
495 ; X86-NEXT: calll memcmp
496 ; X86-NEXT: addl $16, %esp
499 ; X64-LABEL: length24:
501 ; X64-NEXT: pushq $24
502 ; X64-NEXT: popq %rdx
503 ; X64-NEXT: jmp memcmp # TAILCALL
504 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 24) nounwind
508 define i1 @length24_eq(i8* %x, i8* %y) nounwind minsize {
509 ; X86-LABEL: length24_eq:
512 ; X86-NEXT: pushl $24
513 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
514 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
515 ; X86-NEXT: calll memcmp
516 ; X86-NEXT: addl $16, %esp
517 ; X86-NEXT: testl %eax, %eax
521 ; X64-LABEL: length24_eq:
523 ; X64-NEXT: pushq %rax
524 ; X64-NEXT: pushq $24
525 ; X64-NEXT: popq %rdx
526 ; X64-NEXT: callq memcmp
527 ; X64-NEXT: testl %eax, %eax
529 ; X64-NEXT: popq %rcx
531 %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 24) nounwind
532 %cmp = icmp eq i32 %call, 0
536 define i1 @length24_eq_const(i8* %X) nounwind minsize {
537 ; X86-LABEL: length24_eq_const:
540 ; X86-NEXT: pushl $24
541 ; X86-NEXT: pushl $.L.str
542 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
543 ; X86-NEXT: calll memcmp
544 ; X86-NEXT: addl $16, %esp
545 ; X86-NEXT: testl %eax, %eax
546 ; X86-NEXT: setne %al
549 ; X64-LABEL: length24_eq_const:
551 ; X64-NEXT: pushq %rax
552 ; X64-NEXT: pushq $24
553 ; X64-NEXT: popq %rdx
554 ; X64-NEXT: movl $.L.str, %esi
555 ; X64-NEXT: callq memcmp
556 ; X64-NEXT: testl %eax, %eax
557 ; X64-NEXT: setne %al
558 ; X64-NEXT: popq %rcx
560 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 24) nounwind
561 %c = icmp ne i32 %m, 0
565 define i32 @length32(i8* %X, i8* %Y) nounwind minsize {
566 ; X86-LABEL: length32:
569 ; X86-NEXT: pushl $32
570 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
571 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
572 ; X86-NEXT: calll memcmp
573 ; X86-NEXT: addl $16, %esp
576 ; X64-LABEL: length32:
578 ; X64-NEXT: pushq $32
579 ; X64-NEXT: popq %rdx
580 ; X64-NEXT: jmp memcmp # TAILCALL
581 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 32) nounwind
585 ; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325
587 define i1 @length32_eq(i8* %x, i8* %y) nounwind minsize {
588 ; X86-LABEL: length32_eq:
591 ; X86-NEXT: pushl $32
592 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
593 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
594 ; X86-NEXT: calll memcmp
595 ; X86-NEXT: addl $16, %esp
596 ; X86-NEXT: testl %eax, %eax
600 ; X64-SSE2-LABEL: length32_eq:
602 ; X64-SSE2-NEXT: pushq %rax
603 ; X64-SSE2-NEXT: pushq $32
604 ; X64-SSE2-NEXT: popq %rdx
605 ; X64-SSE2-NEXT: callq memcmp
606 ; X64-SSE2-NEXT: testl %eax, %eax
607 ; X64-SSE2-NEXT: sete %al
608 ; X64-SSE2-NEXT: popq %rcx
609 ; X64-SSE2-NEXT: retq
611 ; X64-AVX1-LABEL: length32_eq:
613 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
614 ; X64-AVX1-NEXT: vxorps (%rsi), %ymm0, %ymm0
615 ; X64-AVX1-NEXT: vptest %ymm0, %ymm
616 ; X64-AVX1-NEXT: sete %al
617 ; X64-AVX1-NEXT: vzeroupper
618 ; X64-AVX1-NEXT: retq
620 ; X64-AVX2-LABEL: length32_eq:
622 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
623 ; X64-AVX2-NEXT: vpxor (%rsi), %ymm0, %ymm0
624 ; X64-AVX2-NEXT: vptest %ymm0, %ymm
625 ; X64-AVX2-NEXT: sete %al
626 ; X64-AVX2-NEXT: vzeroupper
627 ; X64-AVX2-NEXT: retq
628 %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 32) nounwind
629 %cmp = icmp eq i32 %call, 0
633 define i1 @length32_eq_const(i8* %X) nounwind minsize {
634 ; X86-LABEL: length32_eq_const:
637 ; X86-NEXT: pushl $32
638 ; X86-NEXT: pushl $.L.str
639 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
640 ; X86-NEXT: calll memcmp
641 ; X86-NEXT: addl $16, %esp
642 ; X86-NEXT: testl %eax, %eax
643 ; X86-NEXT: setne %al
646 ; X64-SSE2-LABEL: length32_eq_const:
648 ; X64-SSE2-NEXT: pushq %rax
649 ; X64-SSE2-NEXT: pushq $32
650 ; X64-SSE2-NEXT: popq %rdx
651 ; X64-SSE2-NEXT: movl $.L.str, %esi
652 ; X64-SSE2-NEXT: callq memcmp
653 ; X64-SSE2-NEXT: testl %eax, %eax
654 ; X64-SSE2-NEXT: setne %al
655 ; X64-SSE2-NEXT: popq %rcx
656 ; X64-SSE2-NEXT: retq
658 ; X64-AVX1-LABEL: length32_eq_const:
660 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
661 ; X64-AVX1-NEXT: vxorps {{.*}}(%rip), %ymm0, %ymm0
662 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
663 ; X64-AVX1-NEXT: setne %al
664 ; X64-AVX1-NEXT: vzeroupper
665 ; X64-AVX1-NEXT: retq
667 ; X64-AVX2-LABEL: length32_eq_const:
669 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
670 ; X64-AVX2-NEXT: vpxor {{.*}}(%rip), %ymm0, %ymm0
671 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
672 ; X64-AVX2-NEXT: setne %al
673 ; X64-AVX2-NEXT: vzeroupper
674 ; X64-AVX2-NEXT: retq
675 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 32) nounwind
676 %c = icmp ne i32 %m, 0
680 define i32 @length64(i8* %X, i8* %Y) nounwind minsize {
681 ; X86-LABEL: length64:
684 ; X86-NEXT: pushl $64
685 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
686 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
687 ; X86-NEXT: calll memcmp
688 ; X86-NEXT: addl $16, %esp
691 ; X64-LABEL: length64:
693 ; X64-NEXT: pushq $64
694 ; X64-NEXT: popq %rdx
695 ; X64-NEXT: jmp memcmp # TAILCALL
696 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 64) nounwind
700 define i1 @length64_eq(i8* %x, i8* %y) nounwind minsize {
701 ; X86-LABEL: length64_eq:
704 ; X86-NEXT: pushl $64
705 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
706 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
707 ; X86-NEXT: calll memcmp
708 ; X86-NEXT: addl $16, %esp
709 ; X86-NEXT: testl %eax, %eax
710 ; X86-NEXT: setne %al
713 ; X64-LABEL: length64_eq:
715 ; X64-NEXT: pushq %rax
716 ; X64-NEXT: pushq $64
717 ; X64-NEXT: popq %rdx
718 ; X64-NEXT: callq memcmp
719 ; X64-NEXT: testl %eax, %eax
720 ; X64-NEXT: setne %al
721 ; X64-NEXT: popq %rcx
723 %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 64) nounwind
724 %cmp = icmp ne i32 %call, 0
728 define i1 @length64_eq_const(i8* %X) nounwind minsize {
729 ; X86-LABEL: length64_eq_const:
732 ; X86-NEXT: pushl $64
733 ; X86-NEXT: pushl $.L.str
734 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
735 ; X86-NEXT: calll memcmp
736 ; X86-NEXT: addl $16, %esp
737 ; X86-NEXT: testl %eax, %eax
741 ; X64-LABEL: length64_eq_const:
743 ; X64-NEXT: pushq %rax
744 ; X64-NEXT: pushq $64
745 ; X64-NEXT: popq %rdx
746 ; X64-NEXT: movl $.L.str, %esi
747 ; X64-NEXT: callq memcmp
748 ; X64-NEXT: testl %eax, %eax
750 ; X64-NEXT: popq %rcx
752 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 64) nounwind
753 %c = icmp eq i32 %m, 0