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=+sse | FileCheck %s --check-prefix=X86 --check-prefix=SSE --check-prefix=X86-SSE1
4 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86 --check-prefix=SSE --check-prefix=X86-SSE2
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64 --check-prefix=X64-SSE2
6 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s --check-prefix=X64 --check-prefix=X64-AVX --check-prefix=X64-AVX1
7 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx2 | FileCheck %s --check-prefix=X64 --check-prefix=X64-AVX --check-prefix=X64-AVX2
9 ; This tests codegen time inlining/optimization of memcmp
12 @.str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 1
14 declare i32 @memcmp(i8*, i8*, i64)
16 define i32 @length0(i8* %X, i8* %Y) nounwind {
19 ; X86-NEXT: xorl %eax, %eax
24 ; X64-NEXT: xorl %eax, %eax
26 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 0) nounwind
30 define i1 @length0_eq(i8* %X, i8* %Y) nounwind {
31 ; X86-LABEL: length0_eq:
33 ; X86-NEXT: movb $1, %al
36 ; X64-LABEL: length0_eq:
38 ; X64-NEXT: movb $1, %al
40 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 0) nounwind
41 %c = icmp eq i32 %m, 0
45 define i1 @length0_lt(i8* %X, i8* %Y) nounwind {
46 ; X86-LABEL: length0_lt:
48 ; X86-NEXT: xorl %eax, %eax
51 ; X64-LABEL: length0_lt:
53 ; X64-NEXT: xorl %eax, %eax
55 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 0) nounwind
56 %c = icmp slt i32 %m, 0
60 define i32 @length2(i8* %X, i8* %Y) nounwind {
63 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
64 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
65 ; X86-NEXT: movzwl (%ecx), %ecx
66 ; X86-NEXT: movzwl (%eax), %edx
67 ; X86-NEXT: rolw $8, %cx
68 ; X86-NEXT: rolw $8, %dx
69 ; X86-NEXT: movzwl %cx, %eax
70 ; X86-NEXT: movzwl %dx, %ecx
71 ; X86-NEXT: subl %ecx, %eax
76 ; X64-NEXT: movzwl (%rdi), %eax
77 ; X64-NEXT: movzwl (%rsi), %ecx
78 ; X64-NEXT: rolw $8, %ax
79 ; X64-NEXT: rolw $8, %cx
80 ; X64-NEXT: movzwl %ax, %eax
81 ; X64-NEXT: movzwl %cx, %ecx
82 ; X64-NEXT: subl %ecx, %eax
84 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind
88 define i1 @length2_eq(i8* %X, i8* %Y) nounwind {
89 ; X86-LABEL: length2_eq:
91 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
92 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
93 ; X86-NEXT: movzwl (%ecx), %ecx
94 ; X86-NEXT: cmpw (%eax), %cx
98 ; X64-LABEL: length2_eq:
100 ; X64-NEXT: movzwl (%rdi), %eax
101 ; X64-NEXT: cmpw (%rsi), %ax
104 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind
105 %c = icmp eq i32 %m, 0
109 define i1 @length2_lt(i8* %X, i8* %Y) nounwind {
110 ; X86-LABEL: length2_lt:
112 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
113 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
114 ; X86-NEXT: movzwl (%ecx), %ecx
115 ; X86-NEXT: movzwl (%eax), %edx
116 ; X86-NEXT: rolw $8, %cx
117 ; X86-NEXT: rolw $8, %dx
118 ; X86-NEXT: movzwl %cx, %eax
119 ; X86-NEXT: movzwl %dx, %ecx
120 ; X86-NEXT: subl %ecx, %eax
121 ; X86-NEXT: shrl $31, %eax
122 ; X86-NEXT: # kill: def $al killed $al killed $eax
125 ; X64-LABEL: length2_lt:
127 ; X64-NEXT: movzwl (%rdi), %eax
128 ; X64-NEXT: movzwl (%rsi), %ecx
129 ; X64-NEXT: rolw $8, %ax
130 ; X64-NEXT: rolw $8, %cx
131 ; X64-NEXT: movzwl %ax, %eax
132 ; X64-NEXT: movzwl %cx, %ecx
133 ; X64-NEXT: subl %ecx, %eax
134 ; X64-NEXT: shrl $31, %eax
135 ; X64-NEXT: # kill: def $al killed $al killed $eax
137 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind
138 %c = icmp slt i32 %m, 0
142 define i1 @length2_gt(i8* %X, i8* %Y) nounwind {
143 ; X86-LABEL: length2_gt:
145 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
146 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
147 ; X86-NEXT: movzwl (%ecx), %ecx
148 ; X86-NEXT: movzwl (%eax), %eax
149 ; X86-NEXT: rolw $8, %cx
150 ; X86-NEXT: rolw $8, %ax
151 ; X86-NEXT: movzwl %cx, %ecx
152 ; X86-NEXT: movzwl %ax, %eax
153 ; X86-NEXT: subl %eax, %ecx
154 ; X86-NEXT: testl %ecx, %ecx
158 ; X64-LABEL: length2_gt:
160 ; X64-NEXT: movzwl (%rdi), %eax
161 ; X64-NEXT: movzwl (%rsi), %ecx
162 ; X64-NEXT: rolw $8, %ax
163 ; X64-NEXT: rolw $8, %cx
164 ; X64-NEXT: movzwl %ax, %eax
165 ; X64-NEXT: movzwl %cx, %ecx
166 ; X64-NEXT: subl %ecx, %eax
167 ; X64-NEXT: testl %eax, %eax
170 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind
171 %c = icmp sgt i32 %m, 0
175 define i1 @length2_eq_const(i8* %X) nounwind {
176 ; X86-LABEL: length2_eq_const:
178 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
179 ; X86-NEXT: movzwl (%eax), %eax
180 ; X86-NEXT: cmpl $12849, %eax # imm = 0x3231
181 ; X86-NEXT: setne %al
184 ; X64-LABEL: length2_eq_const:
186 ; X64-NEXT: movzwl (%rdi), %eax
187 ; X64-NEXT: cmpl $12849, %eax # imm = 0x3231
188 ; X64-NEXT: setne %al
190 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 1), i64 2) nounwind
191 %c = icmp ne i32 %m, 0
195 define i1 @length2_eq_nobuiltin_attr(i8* %X, i8* %Y) nounwind {
196 ; X86-LABEL: length2_eq_nobuiltin_attr:
200 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
201 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
202 ; X86-NEXT: calll memcmp
203 ; X86-NEXT: addl $16, %esp
204 ; X86-NEXT: testl %eax, %eax
208 ; X64-LABEL: length2_eq_nobuiltin_attr:
210 ; X64-NEXT: pushq %rax
211 ; X64-NEXT: movl $2, %edx
212 ; X64-NEXT: callq memcmp
213 ; X64-NEXT: testl %eax, %eax
215 ; X64-NEXT: popq %rcx
217 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind nobuiltin
218 %c = icmp eq i32 %m, 0
222 define i32 @length3(i8* %X, i8* %Y) nounwind {
223 ; X86-LABEL: length3:
224 ; X86: # %bb.0: # %loadbb
225 ; X86-NEXT: pushl %esi
226 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
227 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
228 ; X86-NEXT: movzwl (%eax), %edx
229 ; X86-NEXT: movzwl (%ecx), %esi
230 ; X86-NEXT: rolw $8, %dx
231 ; X86-NEXT: rolw $8, %si
232 ; X86-NEXT: cmpw %si, %dx
233 ; X86-NEXT: jne .LBB9_1
234 ; X86-NEXT: # %bb.2: # %loadbb1
235 ; X86-NEXT: movzbl 2(%eax), %eax
236 ; X86-NEXT: movzbl 2(%ecx), %ecx
237 ; X86-NEXT: subl %ecx, %eax
238 ; X86-NEXT: popl %esi
240 ; X86-NEXT: .LBB9_1: # %res_block
241 ; X86-NEXT: setae %al
242 ; X86-NEXT: movzbl %al, %eax
243 ; X86-NEXT: leal -1(%eax,%eax), %eax
244 ; X86-NEXT: popl %esi
247 ; X64-LABEL: length3:
248 ; X64: # %bb.0: # %loadbb
249 ; X64-NEXT: movzwl (%rdi), %eax
250 ; X64-NEXT: movzwl (%rsi), %ecx
251 ; X64-NEXT: rolw $8, %ax
252 ; X64-NEXT: rolw $8, %cx
253 ; X64-NEXT: cmpw %cx, %ax
254 ; X64-NEXT: jne .LBB9_1
255 ; X64-NEXT: # %bb.2: # %loadbb1
256 ; X64-NEXT: movzbl 2(%rdi), %eax
257 ; X64-NEXT: movzbl 2(%rsi), %ecx
258 ; X64-NEXT: subl %ecx, %eax
260 ; X64-NEXT: .LBB9_1: # %res_block
261 ; X64-NEXT: setae %al
262 ; X64-NEXT: movzbl %al, %eax
263 ; X64-NEXT: leal -1(%rax,%rax), %eax
265 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 3) nounwind
269 define i1 @length3_eq(i8* %X, i8* %Y) nounwind {
270 ; X86-LABEL: length3_eq:
272 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
273 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
274 ; X86-NEXT: movzwl (%ecx), %edx
275 ; X86-NEXT: xorw (%eax), %dx
276 ; X86-NEXT: movb 2(%ecx), %cl
277 ; X86-NEXT: xorb 2(%eax), %cl
278 ; X86-NEXT: movzbl %cl, %eax
279 ; X86-NEXT: orw %dx, %ax
280 ; X86-NEXT: setne %al
283 ; X64-LABEL: length3_eq:
285 ; X64-NEXT: movzwl (%rdi), %eax
286 ; X64-NEXT: xorw (%rsi), %ax
287 ; X64-NEXT: movb 2(%rdi), %cl
288 ; X64-NEXT: xorb 2(%rsi), %cl
289 ; X64-NEXT: movzbl %cl, %ecx
290 ; X64-NEXT: orw %ax, %cx
291 ; X64-NEXT: setne %al
293 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 3) nounwind
294 %c = icmp ne i32 %m, 0
298 define i32 @length4(i8* %X, i8* %Y) nounwind {
299 ; X86-LABEL: length4:
301 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
302 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
303 ; X86-NEXT: movl (%ecx), %ecx
304 ; X86-NEXT: movl (%eax), %edx
305 ; X86-NEXT: bswapl %ecx
306 ; X86-NEXT: bswapl %edx
307 ; X86-NEXT: xorl %eax, %eax
308 ; X86-NEXT: cmpl %edx, %ecx
310 ; X86-NEXT: sbbl $0, %eax
313 ; X64-LABEL: length4:
315 ; X64-NEXT: movl (%rdi), %ecx
316 ; X64-NEXT: movl (%rsi), %edx
317 ; X64-NEXT: bswapl %ecx
318 ; X64-NEXT: bswapl %edx
319 ; X64-NEXT: xorl %eax, %eax
320 ; X64-NEXT: cmpl %edx, %ecx
322 ; X64-NEXT: sbbl $0, %eax
324 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind
328 define i1 @length4_eq(i8* %X, i8* %Y) nounwind {
329 ; X86-LABEL: length4_eq:
331 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
332 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
333 ; X86-NEXT: movl (%ecx), %ecx
334 ; X86-NEXT: cmpl (%eax), %ecx
335 ; X86-NEXT: setne %al
338 ; X64-LABEL: length4_eq:
340 ; X64-NEXT: movl (%rdi), %eax
341 ; X64-NEXT: cmpl (%rsi), %eax
342 ; X64-NEXT: setne %al
344 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind
345 %c = icmp ne i32 %m, 0
349 define i1 @length4_lt(i8* %X, i8* %Y) nounwind {
350 ; X86-LABEL: length4_lt:
352 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
353 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
354 ; X86-NEXT: movl (%ecx), %ecx
355 ; X86-NEXT: movl (%eax), %edx
356 ; X86-NEXT: bswapl %ecx
357 ; X86-NEXT: bswapl %edx
358 ; X86-NEXT: xorl %eax, %eax
359 ; X86-NEXT: cmpl %edx, %ecx
361 ; X86-NEXT: sbbl $0, %eax
362 ; X86-NEXT: shrl $31, %eax
363 ; X86-NEXT: # kill: def $al killed $al killed $eax
366 ; X64-LABEL: length4_lt:
368 ; X64-NEXT: movl (%rdi), %ecx
369 ; X64-NEXT: movl (%rsi), %edx
370 ; X64-NEXT: bswapl %ecx
371 ; X64-NEXT: bswapl %edx
372 ; X64-NEXT: xorl %eax, %eax
373 ; X64-NEXT: cmpl %edx, %ecx
375 ; X64-NEXT: sbbl $0, %eax
376 ; X64-NEXT: shrl $31, %eax
377 ; X64-NEXT: # kill: def $al killed $al killed $eax
379 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind
380 %c = icmp slt i32 %m, 0
384 define i1 @length4_gt(i8* %X, i8* %Y) nounwind {
385 ; X86-LABEL: length4_gt:
387 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
388 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
389 ; X86-NEXT: movl (%ecx), %ecx
390 ; X86-NEXT: movl (%eax), %eax
391 ; X86-NEXT: bswapl %ecx
392 ; X86-NEXT: bswapl %eax
393 ; X86-NEXT: xorl %edx, %edx
394 ; X86-NEXT: cmpl %eax, %ecx
396 ; X86-NEXT: sbbl $0, %edx
397 ; X86-NEXT: testl %edx, %edx
401 ; X64-LABEL: length4_gt:
403 ; X64-NEXT: movl (%rdi), %eax
404 ; X64-NEXT: movl (%rsi), %ecx
405 ; X64-NEXT: bswapl %eax
406 ; X64-NEXT: bswapl %ecx
407 ; X64-NEXT: xorl %edx, %edx
408 ; X64-NEXT: cmpl %ecx, %eax
410 ; X64-NEXT: sbbl $0, %edx
411 ; X64-NEXT: testl %edx, %edx
414 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind
415 %c = icmp sgt i32 %m, 0
419 define i1 @length4_eq_const(i8* %X) nounwind {
420 ; X86-LABEL: length4_eq_const:
422 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
423 ; X86-NEXT: cmpl $875770417, (%eax) # imm = 0x34333231
427 ; X64-LABEL: length4_eq_const:
429 ; X64-NEXT: cmpl $875770417, (%rdi) # imm = 0x34333231
432 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 1), i64 4) nounwind
433 %c = icmp eq i32 %m, 0
437 define i32 @length5(i8* %X, i8* %Y) nounwind {
438 ; X86-LABEL: length5:
439 ; X86: # %bb.0: # %loadbb
440 ; X86-NEXT: pushl %esi
441 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
442 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
443 ; X86-NEXT: movl (%eax), %edx
444 ; X86-NEXT: movl (%ecx), %esi
445 ; X86-NEXT: bswapl %edx
446 ; X86-NEXT: bswapl %esi
447 ; X86-NEXT: cmpl %esi, %edx
448 ; X86-NEXT: jne .LBB16_1
449 ; X86-NEXT: # %bb.2: # %loadbb1
450 ; X86-NEXT: movzbl 4(%eax), %eax
451 ; X86-NEXT: movzbl 4(%ecx), %ecx
452 ; X86-NEXT: subl %ecx, %eax
453 ; X86-NEXT: popl %esi
455 ; X86-NEXT: .LBB16_1: # %res_block
456 ; X86-NEXT: setae %al
457 ; X86-NEXT: movzbl %al, %eax
458 ; X86-NEXT: leal -1(%eax,%eax), %eax
459 ; X86-NEXT: popl %esi
462 ; X64-LABEL: length5:
463 ; X64: # %bb.0: # %loadbb
464 ; X64-NEXT: movl (%rdi), %eax
465 ; X64-NEXT: movl (%rsi), %ecx
466 ; X64-NEXT: bswapl %eax
467 ; X64-NEXT: bswapl %ecx
468 ; X64-NEXT: cmpl %ecx, %eax
469 ; X64-NEXT: jne .LBB16_1
470 ; X64-NEXT: # %bb.2: # %loadbb1
471 ; X64-NEXT: movzbl 4(%rdi), %eax
472 ; X64-NEXT: movzbl 4(%rsi), %ecx
473 ; X64-NEXT: subl %ecx, %eax
475 ; X64-NEXT: .LBB16_1: # %res_block
476 ; X64-NEXT: setae %al
477 ; X64-NEXT: movzbl %al, %eax
478 ; X64-NEXT: leal -1(%rax,%rax), %eax
480 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 5) nounwind
484 define i1 @length5_eq(i8* %X, i8* %Y) nounwind {
485 ; X86-LABEL: length5_eq:
487 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
488 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
489 ; X86-NEXT: movl (%ecx), %edx
490 ; X86-NEXT: xorl (%eax), %edx
491 ; X86-NEXT: movb 4(%ecx), %cl
492 ; X86-NEXT: xorb 4(%eax), %cl
493 ; X86-NEXT: movzbl %cl, %eax
494 ; X86-NEXT: orl %edx, %eax
495 ; X86-NEXT: setne %al
498 ; X64-LABEL: length5_eq:
500 ; X64-NEXT: movl (%rdi), %eax
501 ; X64-NEXT: xorl (%rsi), %eax
502 ; X64-NEXT: movb 4(%rdi), %cl
503 ; X64-NEXT: xorb 4(%rsi), %cl
504 ; X64-NEXT: movzbl %cl, %ecx
505 ; X64-NEXT: orl %eax, %ecx
506 ; X64-NEXT: setne %al
508 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 5) nounwind
509 %c = icmp ne i32 %m, 0
513 define i1 @length5_lt(i8* %X, i8* %Y) nounwind {
514 ; X86-LABEL: length5_lt:
515 ; X86: # %bb.0: # %loadbb
516 ; X86-NEXT: pushl %esi
517 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
518 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
519 ; X86-NEXT: movl (%eax), %edx
520 ; X86-NEXT: movl (%ecx), %esi
521 ; X86-NEXT: bswapl %edx
522 ; X86-NEXT: bswapl %esi
523 ; X86-NEXT: cmpl %esi, %edx
524 ; X86-NEXT: jne .LBB18_1
525 ; X86-NEXT: # %bb.2: # %loadbb1
526 ; X86-NEXT: movzbl 4(%eax), %eax
527 ; X86-NEXT: movzbl 4(%ecx), %ecx
528 ; X86-NEXT: subl %ecx, %eax
529 ; X86-NEXT: jmp .LBB18_3
530 ; X86-NEXT: .LBB18_1: # %res_block
531 ; X86-NEXT: setae %al
532 ; X86-NEXT: movzbl %al, %eax
533 ; X86-NEXT: leal -1(%eax,%eax), %eax
534 ; X86-NEXT: .LBB18_3: # %endblock
535 ; X86-NEXT: shrl $31, %eax
536 ; X86-NEXT: # kill: def $al killed $al killed $eax
537 ; X86-NEXT: popl %esi
540 ; X64-LABEL: length5_lt:
541 ; X64: # %bb.0: # %loadbb
542 ; X64-NEXT: movl (%rdi), %eax
543 ; X64-NEXT: movl (%rsi), %ecx
544 ; X64-NEXT: bswapl %eax
545 ; X64-NEXT: bswapl %ecx
546 ; X64-NEXT: cmpl %ecx, %eax
547 ; X64-NEXT: jne .LBB18_1
548 ; X64-NEXT: # %bb.2: # %loadbb1
549 ; X64-NEXT: movzbl 4(%rdi), %eax
550 ; X64-NEXT: movzbl 4(%rsi), %ecx
551 ; X64-NEXT: subl %ecx, %eax
552 ; X64-NEXT: shrl $31, %eax
553 ; X64-NEXT: # kill: def $al killed $al killed $eax
555 ; X64-NEXT: .LBB18_1: # %res_block
556 ; X64-NEXT: setae %al
557 ; X64-NEXT: movzbl %al, %eax
558 ; X64-NEXT: leal -1(%rax,%rax), %eax
559 ; X64-NEXT: shrl $31, %eax
560 ; X64-NEXT: # kill: def $al killed $al killed $eax
562 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 5) nounwind
563 %c = icmp slt i32 %m, 0
567 define i1 @length7_eq(i8* %X, i8* %Y) nounwind {
568 ; X86-LABEL: length7_eq:
570 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
571 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
572 ; X86-NEXT: movl (%ecx), %edx
573 ; X86-NEXT: movl 3(%ecx), %ecx
574 ; X86-NEXT: xorl (%eax), %edx
575 ; X86-NEXT: xorl 3(%eax), %ecx
576 ; X86-NEXT: orl %edx, %ecx
577 ; X86-NEXT: setne %al
580 ; X64-LABEL: length7_eq:
582 ; X64-NEXT: movl (%rdi), %eax
583 ; X64-NEXT: movl 3(%rdi), %ecx
584 ; X64-NEXT: xorl (%rsi), %eax
585 ; X64-NEXT: xorl 3(%rsi), %ecx
586 ; X64-NEXT: orl %eax, %ecx
587 ; X64-NEXT: setne %al
589 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 7) nounwind
590 %c = icmp ne i32 %m, 0
594 define i32 @length8(i8* %X, i8* %Y) nounwind {
595 ; X86-LABEL: length8:
597 ; X86-NEXT: pushl %esi
598 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
599 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
600 ; X86-NEXT: movl (%esi), %ecx
601 ; X86-NEXT: movl (%eax), %edx
602 ; X86-NEXT: bswapl %ecx
603 ; X86-NEXT: bswapl %edx
604 ; X86-NEXT: cmpl %edx, %ecx
605 ; X86-NEXT: jne .LBB20_2
606 ; X86-NEXT: # %bb.1: # %loadbb1
607 ; X86-NEXT: movl 4(%esi), %ecx
608 ; X86-NEXT: movl 4(%eax), %edx
609 ; X86-NEXT: bswapl %ecx
610 ; X86-NEXT: bswapl %edx
611 ; X86-NEXT: xorl %eax, %eax
612 ; X86-NEXT: cmpl %edx, %ecx
613 ; X86-NEXT: je .LBB20_3
614 ; X86-NEXT: .LBB20_2: # %res_block
615 ; X86-NEXT: xorl %eax, %eax
616 ; X86-NEXT: cmpl %edx, %ecx
617 ; X86-NEXT: setae %al
618 ; X86-NEXT: leal -1(%eax,%eax), %eax
619 ; X86-NEXT: .LBB20_3: # %endblock
620 ; X86-NEXT: popl %esi
623 ; X64-LABEL: length8:
625 ; X64-NEXT: movq (%rdi), %rcx
626 ; X64-NEXT: movq (%rsi), %rdx
627 ; X64-NEXT: bswapq %rcx
628 ; X64-NEXT: bswapq %rdx
629 ; X64-NEXT: xorl %eax, %eax
630 ; X64-NEXT: cmpq %rdx, %rcx
632 ; X64-NEXT: sbbl $0, %eax
634 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 8) nounwind
638 define i1 @length8_eq(i8* %X, i8* %Y) nounwind {
639 ; X86-LABEL: length8_eq:
641 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
642 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
643 ; X86-NEXT: movl (%ecx), %edx
644 ; X86-NEXT: movl 4(%ecx), %ecx
645 ; X86-NEXT: xorl (%eax), %edx
646 ; X86-NEXT: xorl 4(%eax), %ecx
647 ; X86-NEXT: orl %edx, %ecx
651 ; X64-LABEL: length8_eq:
653 ; X64-NEXT: movq (%rdi), %rax
654 ; X64-NEXT: cmpq (%rsi), %rax
657 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 8) nounwind
658 %c = icmp eq i32 %m, 0
662 define i1 @length8_eq_const(i8* %X) nounwind {
663 ; X86-LABEL: length8_eq_const:
665 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
666 ; X86-NEXT: movl $858927408, %ecx # imm = 0x33323130
667 ; X86-NEXT: xorl (%eax), %ecx
668 ; X86-NEXT: movl $926299444, %edx # imm = 0x37363534
669 ; X86-NEXT: xorl 4(%eax), %edx
670 ; X86-NEXT: orl %ecx, %edx
671 ; X86-NEXT: setne %al
674 ; X64-LABEL: length8_eq_const:
676 ; X64-NEXT: movabsq $3978425819141910832, %rax # imm = 0x3736353433323130
677 ; X64-NEXT: cmpq %rax, (%rdi)
678 ; X64-NEXT: setne %al
680 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 8) nounwind
681 %c = icmp ne i32 %m, 0
685 define i1 @length9_eq(i8* %X, i8* %Y) nounwind {
686 ; X86-LABEL: length9_eq:
690 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
691 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
692 ; X86-NEXT: calll memcmp
693 ; X86-NEXT: addl $16, %esp
694 ; X86-NEXT: testl %eax, %eax
698 ; X64-LABEL: length9_eq:
700 ; X64-NEXT: movq (%rdi), %rax
701 ; X64-NEXT: xorq (%rsi), %rax
702 ; X64-NEXT: movb 8(%rdi), %cl
703 ; X64-NEXT: xorb 8(%rsi), %cl
704 ; X64-NEXT: movzbl %cl, %ecx
705 ; X64-NEXT: orq %rax, %rcx
708 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 9) nounwind
709 %c = icmp eq i32 %m, 0
713 define i1 @length10_eq(i8* %X, i8* %Y) nounwind {
714 ; X86-LABEL: length10_eq:
717 ; X86-NEXT: pushl $10
718 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
719 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
720 ; X86-NEXT: calll memcmp
721 ; X86-NEXT: addl $16, %esp
722 ; X86-NEXT: testl %eax, %eax
726 ; X64-LABEL: length10_eq:
728 ; X64-NEXT: movq (%rdi), %rax
729 ; X64-NEXT: xorq (%rsi), %rax
730 ; X64-NEXT: movzwl 8(%rdi), %ecx
731 ; X64-NEXT: xorw 8(%rsi), %cx
732 ; X64-NEXT: movzwl %cx, %ecx
733 ; X64-NEXT: orq %rax, %rcx
736 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 10) nounwind
737 %c = icmp eq i32 %m, 0
741 define i1 @length11_eq(i8* %X, i8* %Y) nounwind {
742 ; X86-LABEL: length11_eq:
745 ; X86-NEXT: pushl $11
746 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
747 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
748 ; X86-NEXT: calll memcmp
749 ; X86-NEXT: addl $16, %esp
750 ; X86-NEXT: testl %eax, %eax
754 ; X64-LABEL: length11_eq:
756 ; X64-NEXT: movq (%rdi), %rax
757 ; X64-NEXT: movq 3(%rdi), %rcx
758 ; X64-NEXT: xorq (%rsi), %rax
759 ; X64-NEXT: xorq 3(%rsi), %rcx
760 ; X64-NEXT: orq %rax, %rcx
763 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 11) nounwind
764 %c = icmp eq i32 %m, 0
768 define i1 @length12_eq(i8* %X, i8* %Y) nounwind {
769 ; X86-LABEL: length12_eq:
772 ; X86-NEXT: pushl $12
773 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
774 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
775 ; X86-NEXT: calll memcmp
776 ; X86-NEXT: addl $16, %esp
777 ; X86-NEXT: testl %eax, %eax
778 ; X86-NEXT: setne %al
781 ; X64-LABEL: length12_eq:
783 ; X64-NEXT: movq (%rdi), %rax
784 ; X64-NEXT: xorq (%rsi), %rax
785 ; X64-NEXT: movl 8(%rdi), %ecx
786 ; X64-NEXT: xorl 8(%rsi), %ecx
787 ; X64-NEXT: orq %rax, %rcx
788 ; X64-NEXT: setne %al
790 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 12) nounwind
791 %c = icmp ne i32 %m, 0
795 define i32 @length12(i8* %X, i8* %Y) nounwind {
796 ; X86-LABEL: length12:
799 ; X86-NEXT: pushl $12
800 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
801 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
802 ; X86-NEXT: calll memcmp
803 ; X86-NEXT: addl $16, %esp
806 ; X64-LABEL: length12:
808 ; X64-NEXT: movq (%rdi), %rcx
809 ; X64-NEXT: movq (%rsi), %rdx
810 ; X64-NEXT: bswapq %rcx
811 ; X64-NEXT: bswapq %rdx
812 ; X64-NEXT: cmpq %rdx, %rcx
813 ; X64-NEXT: jne .LBB27_2
814 ; X64-NEXT: # %bb.1: # %loadbb1
815 ; X64-NEXT: movl 8(%rdi), %ecx
816 ; X64-NEXT: movl 8(%rsi), %edx
817 ; X64-NEXT: bswapl %ecx
818 ; X64-NEXT: bswapl %edx
819 ; X64-NEXT: xorl %eax, %eax
820 ; X64-NEXT: cmpq %rdx, %rcx
821 ; X64-NEXT: je .LBB27_3
822 ; X64-NEXT: .LBB27_2: # %res_block
823 ; X64-NEXT: xorl %eax, %eax
824 ; X64-NEXT: cmpq %rdx, %rcx
825 ; X64-NEXT: setae %al
826 ; X64-NEXT: leal -1(%rax,%rax), %eax
827 ; X64-NEXT: .LBB27_3: # %endblock
829 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 12) nounwind
833 define i1 @length13_eq(i8* %X, i8* %Y) nounwind {
834 ; X86-LABEL: length13_eq:
837 ; X86-NEXT: pushl $13
838 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
839 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
840 ; X86-NEXT: calll memcmp
841 ; X86-NEXT: addl $16, %esp
842 ; X86-NEXT: testl %eax, %eax
846 ; X64-LABEL: length13_eq:
848 ; X64-NEXT: movq (%rdi), %rax
849 ; X64-NEXT: movq 5(%rdi), %rcx
850 ; X64-NEXT: xorq (%rsi), %rax
851 ; X64-NEXT: xorq 5(%rsi), %rcx
852 ; X64-NEXT: orq %rax, %rcx
855 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 13) nounwind
856 %c = icmp eq i32 %m, 0
860 define i1 @length14_eq(i8* %X, i8* %Y) nounwind {
861 ; X86-LABEL: length14_eq:
864 ; X86-NEXT: pushl $14
865 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
866 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
867 ; X86-NEXT: calll memcmp
868 ; X86-NEXT: addl $16, %esp
869 ; X86-NEXT: testl %eax, %eax
873 ; X64-LABEL: length14_eq:
875 ; X64-NEXT: movq (%rdi), %rax
876 ; X64-NEXT: movq 6(%rdi), %rcx
877 ; X64-NEXT: xorq (%rsi), %rax
878 ; X64-NEXT: xorq 6(%rsi), %rcx
879 ; X64-NEXT: orq %rax, %rcx
882 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 14) nounwind
883 %c = icmp eq i32 %m, 0
887 define i1 @length15_eq(i8* %X, i8* %Y) nounwind {
888 ; X86-LABEL: length15_eq:
891 ; X86-NEXT: pushl $15
892 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
893 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
894 ; X86-NEXT: calll memcmp
895 ; X86-NEXT: addl $16, %esp
896 ; X86-NEXT: testl %eax, %eax
900 ; X64-LABEL: length15_eq:
902 ; X64-NEXT: movq (%rdi), %rax
903 ; X64-NEXT: movq 7(%rdi), %rcx
904 ; X64-NEXT: xorq (%rsi), %rax
905 ; X64-NEXT: xorq 7(%rsi), %rcx
906 ; X64-NEXT: orq %rax, %rcx
909 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 15) nounwind
910 %c = icmp eq i32 %m, 0
914 ; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329
916 define i32 @length16(i8* %X, i8* %Y) nounwind {
917 ; X86-LABEL: length16:
920 ; X86-NEXT: pushl $16
921 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
922 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
923 ; X86-NEXT: calll memcmp
924 ; X86-NEXT: addl $16, %esp
927 ; X64-LABEL: length16:
929 ; X64-NEXT: movq (%rdi), %rcx
930 ; X64-NEXT: movq (%rsi), %rdx
931 ; X64-NEXT: bswapq %rcx
932 ; X64-NEXT: bswapq %rdx
933 ; X64-NEXT: cmpq %rdx, %rcx
934 ; X64-NEXT: jne .LBB31_2
935 ; X64-NEXT: # %bb.1: # %loadbb1
936 ; X64-NEXT: movq 8(%rdi), %rcx
937 ; X64-NEXT: movq 8(%rsi), %rdx
938 ; X64-NEXT: bswapq %rcx
939 ; X64-NEXT: bswapq %rdx
940 ; X64-NEXT: xorl %eax, %eax
941 ; X64-NEXT: cmpq %rdx, %rcx
942 ; X64-NEXT: je .LBB31_3
943 ; X64-NEXT: .LBB31_2: # %res_block
944 ; X64-NEXT: xorl %eax, %eax
945 ; X64-NEXT: cmpq %rdx, %rcx
946 ; X64-NEXT: setae %al
947 ; X64-NEXT: leal -1(%rax,%rax), %eax
948 ; X64-NEXT: .LBB31_3: # %endblock
950 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 16) nounwind
954 define i1 @length16_eq(i8* %x, i8* %y) nounwind {
955 ; X86-NOSSE-LABEL: length16_eq:
956 ; X86-NOSSE: # %bb.0:
957 ; X86-NOSSE-NEXT: pushl $0
958 ; X86-NOSSE-NEXT: pushl $16
959 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
960 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
961 ; X86-NOSSE-NEXT: calll memcmp
962 ; X86-NOSSE-NEXT: addl $16, %esp
963 ; X86-NOSSE-NEXT: testl %eax, %eax
964 ; X86-NOSSE-NEXT: setne %al
965 ; X86-NOSSE-NEXT: retl
967 ; X86-SSE1-LABEL: length16_eq:
969 ; X86-SSE1-NEXT: pushl $0
970 ; X86-SSE1-NEXT: pushl $16
971 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
972 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
973 ; X86-SSE1-NEXT: calll memcmp
974 ; X86-SSE1-NEXT: addl $16, %esp
975 ; X86-SSE1-NEXT: testl %eax, %eax
976 ; X86-SSE1-NEXT: setne %al
977 ; X86-SSE1-NEXT: retl
979 ; X86-SSE2-LABEL: length16_eq:
981 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
982 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
983 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
984 ; X86-SSE2-NEXT: movdqu (%eax), %xmm1
985 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
986 ; X86-SSE2-NEXT: pmovmskb %xmm1, %eax
987 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
988 ; X86-SSE2-NEXT: setne %al
989 ; X86-SSE2-NEXT: retl
991 ; X64-SSE2-LABEL: length16_eq:
993 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
994 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm1
995 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
996 ; X64-SSE2-NEXT: pmovmskb %xmm1, %eax
997 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
998 ; X64-SSE2-NEXT: setne %al
999 ; X64-SSE2-NEXT: retq
1001 ; X64-AVX-LABEL: length16_eq:
1003 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1004 ; X64-AVX-NEXT: vpcmpeqb (%rsi), %xmm0, %xmm0
1005 ; X64-AVX-NEXT: vpmovmskb %xmm0, %eax
1006 ; X64-AVX-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1007 ; X64-AVX-NEXT: setne %al
1008 ; X64-AVX-NEXT: retq
1009 %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 16) nounwind
1010 %cmp = icmp ne i32 %call, 0
1014 define i1 @length16_eq_const(i8* %X) nounwind {
1015 ; X86-NOSSE-LABEL: length16_eq_const:
1016 ; X86-NOSSE: # %bb.0:
1017 ; X86-NOSSE-NEXT: pushl $0
1018 ; X86-NOSSE-NEXT: pushl $16
1019 ; X86-NOSSE-NEXT: pushl $.L.str
1020 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
1021 ; X86-NOSSE-NEXT: calll memcmp
1022 ; X86-NOSSE-NEXT: addl $16, %esp
1023 ; X86-NOSSE-NEXT: testl %eax, %eax
1024 ; X86-NOSSE-NEXT: sete %al
1025 ; X86-NOSSE-NEXT: retl
1027 ; X86-SSE1-LABEL: length16_eq_const:
1028 ; X86-SSE1: # %bb.0:
1029 ; X86-SSE1-NEXT: pushl $0
1030 ; X86-SSE1-NEXT: pushl $16
1031 ; X86-SSE1-NEXT: pushl $.L.str
1032 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
1033 ; X86-SSE1-NEXT: calll memcmp
1034 ; X86-SSE1-NEXT: addl $16, %esp
1035 ; X86-SSE1-NEXT: testl %eax, %eax
1036 ; X86-SSE1-NEXT: sete %al
1037 ; X86-SSE1-NEXT: retl
1039 ; X86-SSE2-LABEL: length16_eq_const:
1040 ; X86-SSE2: # %bb.0:
1041 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
1042 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
1043 ; X86-SSE2-NEXT: pcmpeqb {{\.LCPI.*}}, %xmm0
1044 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
1045 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1046 ; X86-SSE2-NEXT: sete %al
1047 ; X86-SSE2-NEXT: retl
1049 ; X64-SSE2-LABEL: length16_eq_const:
1050 ; X64-SSE2: # %bb.0:
1051 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1052 ; X64-SSE2-NEXT: pcmpeqb {{.*}}(%rip), %xmm0
1053 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1054 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1055 ; X64-SSE2-NEXT: sete %al
1056 ; X64-SSE2-NEXT: retq
1058 ; X64-AVX-LABEL: length16_eq_const:
1060 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1061 ; X64-AVX-NEXT: vpcmpeqb {{.*}}(%rip), %xmm0, %xmm0
1062 ; X64-AVX-NEXT: vpmovmskb %xmm0, %eax
1063 ; X64-AVX-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1064 ; X64-AVX-NEXT: sete %al
1065 ; X64-AVX-NEXT: retq
1066 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 16) nounwind
1067 %c = icmp eq i32 %m, 0
1071 ; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914
1073 define i32 @length24(i8* %X, i8* %Y) nounwind {
1074 ; X86-LABEL: length24:
1076 ; X86-NEXT: pushl $0
1077 ; X86-NEXT: pushl $24
1078 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1079 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1080 ; X86-NEXT: calll memcmp
1081 ; X86-NEXT: addl $16, %esp
1084 ; X64-LABEL: length24:
1086 ; X64-NEXT: movl $24, %edx
1087 ; X64-NEXT: jmp memcmp # TAILCALL
1088 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 24) nounwind
1092 define i1 @length24_eq(i8* %x, i8* %y) nounwind {
1093 ; X86-NOSSE-LABEL: length24_eq:
1094 ; X86-NOSSE: # %bb.0:
1095 ; X86-NOSSE-NEXT: pushl $0
1096 ; X86-NOSSE-NEXT: pushl $24
1097 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
1098 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
1099 ; X86-NOSSE-NEXT: calll memcmp
1100 ; X86-NOSSE-NEXT: addl $16, %esp
1101 ; X86-NOSSE-NEXT: testl %eax, %eax
1102 ; X86-NOSSE-NEXT: sete %al
1103 ; X86-NOSSE-NEXT: retl
1105 ; X86-SSE1-LABEL: length24_eq:
1106 ; X86-SSE1: # %bb.0:
1107 ; X86-SSE1-NEXT: pushl $0
1108 ; X86-SSE1-NEXT: pushl $24
1109 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
1110 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
1111 ; X86-SSE1-NEXT: calll memcmp
1112 ; X86-SSE1-NEXT: addl $16, %esp
1113 ; X86-SSE1-NEXT: testl %eax, %eax
1114 ; X86-SSE1-NEXT: sete %al
1115 ; X86-SSE1-NEXT: retl
1117 ; X86-SSE2-LABEL: length24_eq:
1118 ; X86-SSE2: # %bb.0:
1119 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
1120 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
1121 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
1122 ; X86-SSE2-NEXT: movdqu 8(%ecx), %xmm1
1123 ; X86-SSE2-NEXT: movdqu (%eax), %xmm2
1124 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
1125 ; X86-SSE2-NEXT: movdqu 8(%eax), %xmm0
1126 ; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
1127 ; X86-SSE2-NEXT: pand %xmm2, %xmm0
1128 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
1129 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1130 ; X86-SSE2-NEXT: sete %al
1131 ; X86-SSE2-NEXT: retl
1133 ; X64-SSE2-LABEL: length24_eq:
1134 ; X64-SSE2: # %bb.0:
1135 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1136 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm1
1137 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
1138 ; X64-SSE2-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
1139 ; X64-SSE2-NEXT: movq {{.*#+}} xmm2 = mem[0],zero
1140 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
1141 ; X64-SSE2-NEXT: pand %xmm1, %xmm2
1142 ; X64-SSE2-NEXT: pmovmskb %xmm2, %eax
1143 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1144 ; X64-SSE2-NEXT: sete %al
1145 ; X64-SSE2-NEXT: retq
1147 ; X64-AVX-LABEL: length24_eq:
1149 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1150 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm1 = mem[0],zero
1151 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm2 = mem[0],zero
1152 ; X64-AVX-NEXT: vpcmpeqb %xmm2, %xmm1, %xmm1
1153 ; X64-AVX-NEXT: vpcmpeqb (%rsi), %xmm0, %xmm0
1154 ; X64-AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
1155 ; X64-AVX-NEXT: vpmovmskb %xmm0, %eax
1156 ; X64-AVX-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1157 ; X64-AVX-NEXT: sete %al
1158 ; X64-AVX-NEXT: retq
1159 %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 24) nounwind
1160 %cmp = icmp eq i32 %call, 0
1164 define i1 @length24_eq_const(i8* %X) nounwind {
1165 ; X86-NOSSE-LABEL: length24_eq_const:
1166 ; X86-NOSSE: # %bb.0:
1167 ; X86-NOSSE-NEXT: pushl $0
1168 ; X86-NOSSE-NEXT: pushl $24
1169 ; X86-NOSSE-NEXT: pushl $.L.str
1170 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
1171 ; X86-NOSSE-NEXT: calll memcmp
1172 ; X86-NOSSE-NEXT: addl $16, %esp
1173 ; X86-NOSSE-NEXT: testl %eax, %eax
1174 ; X86-NOSSE-NEXT: setne %al
1175 ; X86-NOSSE-NEXT: retl
1177 ; X86-SSE1-LABEL: length24_eq_const:
1178 ; X86-SSE1: # %bb.0:
1179 ; X86-SSE1-NEXT: pushl $0
1180 ; X86-SSE1-NEXT: pushl $24
1181 ; X86-SSE1-NEXT: pushl $.L.str
1182 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
1183 ; X86-SSE1-NEXT: calll memcmp
1184 ; X86-SSE1-NEXT: addl $16, %esp
1185 ; X86-SSE1-NEXT: testl %eax, %eax
1186 ; X86-SSE1-NEXT: setne %al
1187 ; X86-SSE1-NEXT: retl
1189 ; X86-SSE2-LABEL: length24_eq_const:
1190 ; X86-SSE2: # %bb.0:
1191 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
1192 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
1193 ; X86-SSE2-NEXT: movdqu 8(%eax), %xmm1
1194 ; X86-SSE2-NEXT: pcmpeqb {{\.LCPI.*}}, %xmm1
1195 ; X86-SSE2-NEXT: pcmpeqb {{\.LCPI.*}}, %xmm0
1196 ; X86-SSE2-NEXT: pand %xmm1, %xmm0
1197 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
1198 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1199 ; X86-SSE2-NEXT: setne %al
1200 ; X86-SSE2-NEXT: retl
1202 ; X64-SSE2-LABEL: length24_eq_const:
1203 ; X64-SSE2: # %bb.0:
1204 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1205 ; X64-SSE2-NEXT: movq {{.*#+}} xmm1 = mem[0],zero
1206 ; X64-SSE2-NEXT: pcmpeqb {{.*}}(%rip), %xmm1
1207 ; X64-SSE2-NEXT: pcmpeqb {{.*}}(%rip), %xmm0
1208 ; X64-SSE2-NEXT: pand %xmm1, %xmm0
1209 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1210 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1211 ; X64-SSE2-NEXT: setne %al
1212 ; X64-SSE2-NEXT: retq
1214 ; X64-AVX-LABEL: length24_eq_const:
1216 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1217 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm1 = mem[0],zero
1218 ; X64-AVX-NEXT: vpcmpeqb {{.*}}(%rip), %xmm1, %xmm1
1219 ; X64-AVX-NEXT: vpcmpeqb {{.*}}(%rip), %xmm0, %xmm0
1220 ; X64-AVX-NEXT: vpand %xmm1, %xmm0, %xmm0
1221 ; X64-AVX-NEXT: vpmovmskb %xmm0, %eax
1222 ; X64-AVX-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1223 ; X64-AVX-NEXT: setne %al
1224 ; X64-AVX-NEXT: retq
1225 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 24) nounwind
1226 %c = icmp ne i32 %m, 0
1230 define i32 @length32(i8* %X, i8* %Y) nounwind {
1231 ; X86-LABEL: length32:
1233 ; X86-NEXT: pushl $0
1234 ; X86-NEXT: pushl $32
1235 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1236 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1237 ; X86-NEXT: calll memcmp
1238 ; X86-NEXT: addl $16, %esp
1241 ; X64-LABEL: length32:
1243 ; X64-NEXT: movl $32, %edx
1244 ; X64-NEXT: jmp memcmp # TAILCALL
1245 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 32) nounwind
1249 ; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325
1251 define i1 @length32_eq(i8* %x, i8* %y) nounwind {
1252 ; X86-NOSSE-LABEL: length32_eq:
1253 ; X86-NOSSE: # %bb.0:
1254 ; X86-NOSSE-NEXT: pushl $0
1255 ; X86-NOSSE-NEXT: pushl $32
1256 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
1257 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
1258 ; X86-NOSSE-NEXT: calll memcmp
1259 ; X86-NOSSE-NEXT: addl $16, %esp
1260 ; X86-NOSSE-NEXT: testl %eax, %eax
1261 ; X86-NOSSE-NEXT: sete %al
1262 ; X86-NOSSE-NEXT: retl
1264 ; X86-SSE1-LABEL: length32_eq:
1265 ; X86-SSE1: # %bb.0:
1266 ; X86-SSE1-NEXT: pushl $0
1267 ; X86-SSE1-NEXT: pushl $32
1268 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
1269 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
1270 ; X86-SSE1-NEXT: calll memcmp
1271 ; X86-SSE1-NEXT: addl $16, %esp
1272 ; X86-SSE1-NEXT: testl %eax, %eax
1273 ; X86-SSE1-NEXT: sete %al
1274 ; X86-SSE1-NEXT: retl
1276 ; X86-SSE2-LABEL: length32_eq:
1277 ; X86-SSE2: # %bb.0:
1278 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
1279 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
1280 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
1281 ; X86-SSE2-NEXT: movdqu 16(%ecx), %xmm1
1282 ; X86-SSE2-NEXT: movdqu (%eax), %xmm2
1283 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
1284 ; X86-SSE2-NEXT: movdqu 16(%eax), %xmm0
1285 ; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
1286 ; X86-SSE2-NEXT: pand %xmm2, %xmm0
1287 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
1288 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1289 ; X86-SSE2-NEXT: sete %al
1290 ; X86-SSE2-NEXT: retl
1292 ; X64-SSE2-LABEL: length32_eq:
1293 ; X64-SSE2: # %bb.0:
1294 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1295 ; X64-SSE2-NEXT: movdqu 16(%rdi), %xmm1
1296 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm2
1297 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
1298 ; X64-SSE2-NEXT: movdqu 16(%rsi), %xmm0
1299 ; X64-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
1300 ; X64-SSE2-NEXT: pand %xmm2, %xmm0
1301 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1302 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1303 ; X64-SSE2-NEXT: sete %al
1304 ; X64-SSE2-NEXT: retq
1306 ; X64-AVX1-LABEL: length32_eq:
1307 ; X64-AVX1: # %bb.0:
1308 ; X64-AVX1-NEXT: vmovdqu (%rdi), %xmm0
1309 ; X64-AVX1-NEXT: vmovdqu 16(%rdi), %xmm1
1310 ; X64-AVX1-NEXT: vpcmpeqb 16(%rsi), %xmm1, %xmm1
1311 ; X64-AVX1-NEXT: vpcmpeqb (%rsi), %xmm0, %xmm0
1312 ; X64-AVX1-NEXT: vpand %xmm1, %xmm0, %xmm0
1313 ; X64-AVX1-NEXT: vpmovmskb %xmm0, %eax
1314 ; X64-AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1315 ; X64-AVX1-NEXT: sete %al
1316 ; X64-AVX1-NEXT: retq
1318 ; X64-AVX2-LABEL: length32_eq:
1319 ; X64-AVX2: # %bb.0:
1320 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1321 ; X64-AVX2-NEXT: vpcmpeqb (%rsi), %ymm0, %ymm0
1322 ; X64-AVX2-NEXT: vpmovmskb %ymm0, %eax
1323 ; X64-AVX2-NEXT: cmpl $-1, %eax
1324 ; X64-AVX2-NEXT: sete %al
1325 ; X64-AVX2-NEXT: vzeroupper
1326 ; X64-AVX2-NEXT: retq
1327 %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 32) nounwind
1328 %cmp = icmp eq i32 %call, 0
1332 define i1 @length32_eq_const(i8* %X) nounwind {
1333 ; X86-NOSSE-LABEL: length32_eq_const:
1334 ; X86-NOSSE: # %bb.0:
1335 ; X86-NOSSE-NEXT: pushl $0
1336 ; X86-NOSSE-NEXT: pushl $32
1337 ; X86-NOSSE-NEXT: pushl $.L.str
1338 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
1339 ; X86-NOSSE-NEXT: calll memcmp
1340 ; X86-NOSSE-NEXT: addl $16, %esp
1341 ; X86-NOSSE-NEXT: testl %eax, %eax
1342 ; X86-NOSSE-NEXT: setne %al
1343 ; X86-NOSSE-NEXT: retl
1345 ; X86-SSE1-LABEL: length32_eq_const:
1346 ; X86-SSE1: # %bb.0:
1347 ; X86-SSE1-NEXT: pushl $0
1348 ; X86-SSE1-NEXT: pushl $32
1349 ; X86-SSE1-NEXT: pushl $.L.str
1350 ; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp)
1351 ; X86-SSE1-NEXT: calll memcmp
1352 ; X86-SSE1-NEXT: addl $16, %esp
1353 ; X86-SSE1-NEXT: testl %eax, %eax
1354 ; X86-SSE1-NEXT: setne %al
1355 ; X86-SSE1-NEXT: retl
1357 ; X86-SSE2-LABEL: length32_eq_const:
1358 ; X86-SSE2: # %bb.0:
1359 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
1360 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
1361 ; X86-SSE2-NEXT: movdqu 16(%eax), %xmm1
1362 ; X86-SSE2-NEXT: pcmpeqb {{\.LCPI.*}}, %xmm1
1363 ; X86-SSE2-NEXT: pcmpeqb {{\.LCPI.*}}, %xmm0
1364 ; X86-SSE2-NEXT: pand %xmm1, %xmm0
1365 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
1366 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1367 ; X86-SSE2-NEXT: setne %al
1368 ; X86-SSE2-NEXT: retl
1370 ; X64-SSE2-LABEL: length32_eq_const:
1371 ; X64-SSE2: # %bb.0:
1372 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1373 ; X64-SSE2-NEXT: movdqu 16(%rdi), %xmm1
1374 ; X64-SSE2-NEXT: pcmpeqb {{.*}}(%rip), %xmm1
1375 ; X64-SSE2-NEXT: pcmpeqb {{.*}}(%rip), %xmm0
1376 ; X64-SSE2-NEXT: pand %xmm1, %xmm0
1377 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1378 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1379 ; X64-SSE2-NEXT: setne %al
1380 ; X64-SSE2-NEXT: retq
1382 ; X64-AVX1-LABEL: length32_eq_const:
1383 ; X64-AVX1: # %bb.0:
1384 ; X64-AVX1-NEXT: vmovdqu (%rdi), %xmm0
1385 ; X64-AVX1-NEXT: vmovdqu 16(%rdi), %xmm1
1386 ; X64-AVX1-NEXT: vpcmpeqb {{.*}}(%rip), %xmm1, %xmm1
1387 ; X64-AVX1-NEXT: vpcmpeqb {{.*}}(%rip), %xmm0, %xmm0
1388 ; X64-AVX1-NEXT: vpand %xmm1, %xmm0, %xmm0
1389 ; X64-AVX1-NEXT: vpmovmskb %xmm0, %eax
1390 ; X64-AVX1-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1391 ; X64-AVX1-NEXT: setne %al
1392 ; X64-AVX1-NEXT: retq
1394 ; X64-AVX2-LABEL: length32_eq_const:
1395 ; X64-AVX2: # %bb.0:
1396 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1397 ; X64-AVX2-NEXT: vpcmpeqb {{.*}}(%rip), %ymm0, %ymm0
1398 ; X64-AVX2-NEXT: vpmovmskb %ymm0, %eax
1399 ; X64-AVX2-NEXT: cmpl $-1, %eax
1400 ; X64-AVX2-NEXT: setne %al
1401 ; X64-AVX2-NEXT: vzeroupper
1402 ; X64-AVX2-NEXT: retq
1403 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 32) nounwind
1404 %c = icmp ne i32 %m, 0
1408 define i32 @length64(i8* %X, i8* %Y) nounwind {
1409 ; X86-LABEL: length64:
1411 ; X86-NEXT: pushl $0
1412 ; X86-NEXT: pushl $64
1413 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1414 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1415 ; X86-NEXT: calll memcmp
1416 ; X86-NEXT: addl $16, %esp
1419 ; X64-LABEL: length64:
1421 ; X64-NEXT: movl $64, %edx
1422 ; X64-NEXT: jmp memcmp # TAILCALL
1423 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 64) nounwind
1427 define i1 @length64_eq(i8* %x, i8* %y) nounwind {
1428 ; X86-LABEL: length64_eq:
1430 ; X86-NEXT: pushl $0
1431 ; X86-NEXT: pushl $64
1432 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1433 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1434 ; X86-NEXT: calll memcmp
1435 ; X86-NEXT: addl $16, %esp
1436 ; X86-NEXT: testl %eax, %eax
1437 ; X86-NEXT: setne %al
1440 ; X64-SSE2-LABEL: length64_eq:
1441 ; X64-SSE2: # %bb.0:
1442 ; X64-SSE2-NEXT: pushq %rax
1443 ; X64-SSE2-NEXT: movl $64, %edx
1444 ; X64-SSE2-NEXT: callq memcmp
1445 ; X64-SSE2-NEXT: testl %eax, %eax
1446 ; X64-SSE2-NEXT: setne %al
1447 ; X64-SSE2-NEXT: popq %rcx
1448 ; X64-SSE2-NEXT: retq
1450 ; X64-AVX1-LABEL: length64_eq:
1451 ; X64-AVX1: # %bb.0:
1452 ; X64-AVX1-NEXT: pushq %rax
1453 ; X64-AVX1-NEXT: movl $64, %edx
1454 ; X64-AVX1-NEXT: callq memcmp
1455 ; X64-AVX1-NEXT: testl %eax, %eax
1456 ; X64-AVX1-NEXT: setne %al
1457 ; X64-AVX1-NEXT: popq %rcx
1458 ; X64-AVX1-NEXT: retq
1460 ; X64-AVX2-LABEL: length64_eq:
1461 ; X64-AVX2: # %bb.0:
1462 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1463 ; X64-AVX2-NEXT: vmovdqu 32(%rdi), %ymm1
1464 ; X64-AVX2-NEXT: vpcmpeqb 32(%rsi), %ymm1, %ymm1
1465 ; X64-AVX2-NEXT: vpcmpeqb (%rsi), %ymm0, %ymm0
1466 ; X64-AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
1467 ; X64-AVX2-NEXT: vpmovmskb %ymm0, %eax
1468 ; X64-AVX2-NEXT: cmpl $-1, %eax
1469 ; X64-AVX2-NEXT: setne %al
1470 ; X64-AVX2-NEXT: vzeroupper
1471 ; X64-AVX2-NEXT: retq
1472 %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 64) nounwind
1473 %cmp = icmp ne i32 %call, 0
1477 define i1 @length64_eq_const(i8* %X) nounwind {
1478 ; X86-LABEL: length64_eq_const:
1480 ; X86-NEXT: pushl $0
1481 ; X86-NEXT: pushl $64
1482 ; X86-NEXT: pushl $.L.str
1483 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1484 ; X86-NEXT: calll memcmp
1485 ; X86-NEXT: addl $16, %esp
1486 ; X86-NEXT: testl %eax, %eax
1487 ; X86-NEXT: sete %al
1490 ; X64-SSE2-LABEL: length64_eq_const:
1491 ; X64-SSE2: # %bb.0:
1492 ; X64-SSE2-NEXT: pushq %rax
1493 ; X64-SSE2-NEXT: movl $.L.str, %esi
1494 ; X64-SSE2-NEXT: movl $64, %edx
1495 ; X64-SSE2-NEXT: callq memcmp
1496 ; X64-SSE2-NEXT: testl %eax, %eax
1497 ; X64-SSE2-NEXT: sete %al
1498 ; X64-SSE2-NEXT: popq %rcx
1499 ; X64-SSE2-NEXT: retq
1501 ; X64-AVX1-LABEL: length64_eq_const:
1502 ; X64-AVX1: # %bb.0:
1503 ; X64-AVX1-NEXT: pushq %rax
1504 ; X64-AVX1-NEXT: movl $.L.str, %esi
1505 ; X64-AVX1-NEXT: movl $64, %edx
1506 ; X64-AVX1-NEXT: callq memcmp
1507 ; X64-AVX1-NEXT: testl %eax, %eax
1508 ; X64-AVX1-NEXT: sete %al
1509 ; X64-AVX1-NEXT: popq %rcx
1510 ; X64-AVX1-NEXT: retq
1512 ; X64-AVX2-LABEL: length64_eq_const:
1513 ; X64-AVX2: # %bb.0:
1514 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1515 ; X64-AVX2-NEXT: vmovdqu 32(%rdi), %ymm1
1516 ; X64-AVX2-NEXT: vpcmpeqb {{.*}}(%rip), %ymm1, %ymm1
1517 ; X64-AVX2-NEXT: vpcmpeqb {{.*}}(%rip), %ymm0, %ymm0
1518 ; X64-AVX2-NEXT: vpand %ymm1, %ymm0, %ymm0
1519 ; X64-AVX2-NEXT: vpmovmskb %ymm0, %eax
1520 ; X64-AVX2-NEXT: cmpl $-1, %eax
1521 ; X64-AVX2-NEXT: sete %al
1522 ; X64-AVX2-NEXT: vzeroupper
1523 ; X64-AVX2-NEXT: retq
1524 %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 64) nounwind
1525 %c = icmp eq i32 %m, 0
1529 ; This checks that we do not do stupid things with huge sizes.
1530 define i32 @huge_length(i8* %X, i8* %Y) nounwind {
1531 ; X86-LABEL: huge_length:
1533 ; X86-NEXT: pushl $2147483647 # imm = 0x7FFFFFFF
1534 ; X86-NEXT: pushl $-1
1535 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1536 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1537 ; X86-NEXT: calll memcmp
1538 ; X86-NEXT: addl $16, %esp
1541 ; X64-LABEL: huge_length:
1543 ; X64-NEXT: movabsq $9223372036854775807, %rdx # imm = 0x7FFFFFFFFFFFFFFF
1544 ; X64-NEXT: jmp memcmp # TAILCALL
1545 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 9223372036854775807) nounwind
1549 define i1 @huge_length_eq(i8* %X, i8* %Y) nounwind {
1550 ; X86-LABEL: huge_length_eq:
1552 ; X86-NEXT: pushl $2147483647 # imm = 0x7FFFFFFF
1553 ; X86-NEXT: pushl $-1
1554 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1555 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1556 ; X86-NEXT: calll memcmp
1557 ; X86-NEXT: addl $16, %esp
1558 ; X86-NEXT: testl %eax, %eax
1559 ; X86-NEXT: sete %al
1562 ; X64-LABEL: huge_length_eq:
1564 ; X64-NEXT: pushq %rax
1565 ; X64-NEXT: movabsq $9223372036854775807, %rdx # imm = 0x7FFFFFFFFFFFFFFF
1566 ; X64-NEXT: callq memcmp
1567 ; X64-NEXT: testl %eax, %eax
1568 ; X64-NEXT: sete %al
1569 ; X64-NEXT: popq %rcx
1572 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 9223372036854775807) nounwind
1573 %c = icmp eq i32 %m, 0
1577 ; This checks non-constant sizes.
1578 define i32 @nonconst_length(i8* %X, i8* %Y, i64 %size) nounwind {
1579 ; X86-LABEL: nonconst_length:
1581 ; X86-NEXT: jmp memcmp # TAILCALL
1583 ; X64-LABEL: nonconst_length:
1585 ; X64-NEXT: jmp memcmp # TAILCALL
1586 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 %size) nounwind
1590 define i1 @nonconst_length_eq(i8* %X, i8* %Y, i64 %size) nounwind {
1591 ; X86-LABEL: nonconst_length_eq:
1593 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1594 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1595 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1596 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
1597 ; X86-NEXT: calll memcmp
1598 ; X86-NEXT: addl $16, %esp
1599 ; X86-NEXT: testl %eax, %eax
1600 ; X86-NEXT: sete %al
1603 ; X64-LABEL: nonconst_length_eq:
1605 ; X64-NEXT: pushq %rax
1606 ; X64-NEXT: callq memcmp
1607 ; X64-NEXT: testl %eax, %eax
1608 ; X64-NEXT: sete %al
1609 ; X64-NEXT: popq %rcx
1611 %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 %size) nounwind
1612 %c = icmp eq i32 %m, 0