1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64 --check-prefix=X64-SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s --check-prefix=X64 --check-prefix=X64-AVX --check-prefix=X64-AVX1
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx2 | FileCheck %s --check-prefix=X64 --check-prefix=X64-AVX --check-prefix=X64-AVX2
6 ; This tests codegen time inlining/optimization of memcmp
9 @.str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 1
11 declare dso_local i32 @memcmp(ptr, ptr, i64)
12 declare dso_local i32 @bcmp(ptr, ptr, i64)
14 define i32 @length2(ptr %X, ptr %Y) nounwind optsize {
17 ; X64-NEXT: movzwl (%rdi), %eax
18 ; X64-NEXT: movzwl (%rsi), %ecx
19 ; X64-NEXT: rolw $8, %ax
20 ; X64-NEXT: rolw $8, %cx
21 ; X64-NEXT: movzwl %ax, %eax
22 ; X64-NEXT: movzwl %cx, %ecx
23 ; X64-NEXT: subl %ecx, %eax
25 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind
29 define i1 @length2_eq(ptr %X, ptr %Y) nounwind optsize {
30 ; X64-LABEL: length2_eq:
32 ; X64-NEXT: movzwl (%rdi), %eax
33 ; X64-NEXT: cmpw (%rsi), %ax
36 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind
37 %c = icmp eq i32 %m, 0
41 define i1 @length2_eq_const(ptr %X) nounwind optsize {
42 ; X64-LABEL: length2_eq_const:
44 ; X64-NEXT: movzwl (%rdi), %eax
45 ; X64-NEXT: cmpl $12849, %eax # imm = 0x3231
48 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([65 x i8], ptr @.str, i32 0, i32 1), i64 2) nounwind
49 %c = icmp ne i32 %m, 0
53 define i1 @length2_eq_nobuiltin_attr(ptr %X, ptr %Y) nounwind optsize {
54 ; X64-LABEL: length2_eq_nobuiltin_attr:
56 ; X64-NEXT: pushq %rax
57 ; X64-NEXT: movl $2, %edx
58 ; X64-NEXT: callq memcmp
59 ; X64-NEXT: testl %eax, %eax
63 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind nobuiltin
64 %c = icmp eq i32 %m, 0
68 define i32 @length3(ptr %X, ptr %Y) nounwind optsize {
71 ; X64-NEXT: movzwl (%rdi), %ecx
72 ; X64-NEXT: movzwl (%rsi), %edx
73 ; X64-NEXT: rolw $8, %cx
74 ; X64-NEXT: rolw $8, %dx
75 ; X64-NEXT: cmpw %dx, %cx
76 ; X64-NEXT: jne .LBB4_3
77 ; X64-NEXT: # %bb.1: # %loadbb1
78 ; X64-NEXT: movzbl 2(%rdi), %eax
79 ; X64-NEXT: movzbl 2(%rsi), %ecx
80 ; X64-NEXT: subl %ecx, %eax
82 ; X64-NEXT: .LBB4_3: # %res_block
83 ; X64-NEXT: xorl %eax, %eax
84 ; X64-NEXT: cmpw %dx, %cx
85 ; X64-NEXT: sbbl %eax, %eax
86 ; X64-NEXT: orl $1, %eax
88 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 3) nounwind
92 define i1 @length3_eq(ptr %X, ptr %Y) nounwind optsize {
93 ; X64-LABEL: length3_eq:
95 ; X64-NEXT: movzwl (%rdi), %eax
96 ; X64-NEXT: xorw (%rsi), %ax
97 ; X64-NEXT: movb 2(%rdi), %cl
98 ; X64-NEXT: xorb 2(%rsi), %cl
99 ; X64-NEXT: movzbl %cl, %ecx
100 ; X64-NEXT: orw %ax, %cx
101 ; X64-NEXT: setne %al
103 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 3) nounwind
104 %c = icmp ne i32 %m, 0
108 define i32 @length4(ptr %X, ptr %Y) nounwind optsize {
109 ; X64-LABEL: length4:
111 ; X64-NEXT: movl (%rdi), %ecx
112 ; X64-NEXT: movl (%rsi), %edx
113 ; X64-NEXT: bswapl %ecx
114 ; X64-NEXT: bswapl %edx
115 ; X64-NEXT: xorl %eax, %eax
116 ; X64-NEXT: cmpl %edx, %ecx
118 ; X64-NEXT: sbbl $0, %eax
120 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 4) nounwind
124 define i1 @length4_eq(ptr %X, ptr %Y) nounwind optsize {
125 ; X64-LABEL: length4_eq:
127 ; X64-NEXT: movl (%rdi), %eax
128 ; X64-NEXT: cmpl (%rsi), %eax
129 ; X64-NEXT: setne %al
131 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 4) nounwind
132 %c = icmp ne i32 %m, 0
136 define i1 @length4_eq_const(ptr %X) nounwind optsize {
137 ; X64-LABEL: length4_eq_const:
139 ; X64-NEXT: cmpl $875770417, (%rdi) # imm = 0x34333231
142 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([65 x i8], ptr @.str, i32 0, i32 1), i64 4) nounwind
143 %c = icmp eq i32 %m, 0
147 define i32 @length5(ptr %X, ptr %Y) nounwind optsize {
148 ; X64-LABEL: length5:
150 ; X64-NEXT: movl (%rdi), %ecx
151 ; X64-NEXT: movl (%rsi), %edx
152 ; X64-NEXT: bswapl %ecx
153 ; X64-NEXT: bswapl %edx
154 ; X64-NEXT: cmpl %edx, %ecx
155 ; X64-NEXT: jne .LBB9_3
156 ; X64-NEXT: # %bb.1: # %loadbb1
157 ; X64-NEXT: movzbl 4(%rdi), %eax
158 ; X64-NEXT: movzbl 4(%rsi), %ecx
159 ; X64-NEXT: subl %ecx, %eax
161 ; X64-NEXT: .LBB9_3: # %res_block
162 ; X64-NEXT: xorl %eax, %eax
163 ; X64-NEXT: cmpl %edx, %ecx
164 ; X64-NEXT: sbbl %eax, %eax
165 ; X64-NEXT: orl $1, %eax
167 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 5) nounwind
171 define i1 @length5_eq(ptr %X, ptr %Y) nounwind optsize {
172 ; X64-LABEL: length5_eq:
174 ; X64-NEXT: movl (%rdi), %eax
175 ; X64-NEXT: xorl (%rsi), %eax
176 ; X64-NEXT: movb 4(%rdi), %cl
177 ; X64-NEXT: xorb 4(%rsi), %cl
178 ; X64-NEXT: movzbl %cl, %ecx
179 ; X64-NEXT: orl %eax, %ecx
180 ; X64-NEXT: setne %al
182 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 5) nounwind
183 %c = icmp ne i32 %m, 0
187 define i32 @length8(ptr %X, ptr %Y) nounwind optsize {
188 ; X64-LABEL: length8:
190 ; X64-NEXT: movq (%rdi), %rcx
191 ; X64-NEXT: movq (%rsi), %rdx
192 ; X64-NEXT: bswapq %rcx
193 ; X64-NEXT: bswapq %rdx
194 ; X64-NEXT: xorl %eax, %eax
195 ; X64-NEXT: cmpq %rdx, %rcx
197 ; X64-NEXT: sbbl $0, %eax
199 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 8) nounwind
203 define i1 @length8_eq(ptr %X, ptr %Y) nounwind optsize {
204 ; X64-LABEL: length8_eq:
206 ; X64-NEXT: movq (%rdi), %rax
207 ; X64-NEXT: cmpq (%rsi), %rax
210 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 8) nounwind
211 %c = icmp eq i32 %m, 0
215 define i1 @length8_eq_const(ptr %X) nounwind optsize {
216 ; X64-LABEL: length8_eq_const:
218 ; X64-NEXT: movabsq $3978425819141910832, %rax # imm = 0x3736353433323130
219 ; X64-NEXT: cmpq %rax, (%rdi)
220 ; X64-NEXT: setne %al
222 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 8) nounwind
223 %c = icmp ne i32 %m, 0
227 define i1 @length12_eq(ptr %X, ptr %Y) nounwind optsize {
228 ; X64-LABEL: length12_eq:
230 ; X64-NEXT: movq (%rdi), %rax
231 ; X64-NEXT: xorq (%rsi), %rax
232 ; X64-NEXT: movl 8(%rdi), %ecx
233 ; X64-NEXT: xorl 8(%rsi), %ecx
234 ; X64-NEXT: orq %rax, %rcx
235 ; X64-NEXT: setne %al
237 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 12) nounwind
238 %c = icmp ne i32 %m, 0
242 define i32 @length12(ptr %X, ptr %Y) nounwind optsize {
243 ; X64-LABEL: length12:
245 ; X64-NEXT: movq (%rdi), %rcx
246 ; X64-NEXT: movq (%rsi), %rdx
247 ; X64-NEXT: bswapq %rcx
248 ; X64-NEXT: bswapq %rdx
249 ; X64-NEXT: cmpq %rdx, %rcx
250 ; X64-NEXT: jne .LBB15_2
251 ; X64-NEXT: # %bb.1: # %loadbb1
252 ; X64-NEXT: movl 8(%rdi), %ecx
253 ; X64-NEXT: movl 8(%rsi), %edx
254 ; X64-NEXT: bswapl %ecx
255 ; X64-NEXT: bswapl %edx
256 ; X64-NEXT: xorl %eax, %eax
257 ; X64-NEXT: cmpq %rdx, %rcx
258 ; X64-NEXT: je .LBB15_3
259 ; X64-NEXT: .LBB15_2: # %res_block
260 ; X64-NEXT: xorl %eax, %eax
261 ; X64-NEXT: cmpq %rdx, %rcx
262 ; X64-NEXT: sbbl %eax, %eax
263 ; X64-NEXT: orl $1, %eax
264 ; X64-NEXT: .LBB15_3: # %endblock
266 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 12) nounwind
270 ; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329
272 define i32 @length16(ptr %X, ptr %Y) nounwind optsize {
273 ; X64-LABEL: length16:
275 ; X64-NEXT: movq (%rdi), %rcx
276 ; X64-NEXT: movq (%rsi), %rdx
277 ; X64-NEXT: bswapq %rcx
278 ; X64-NEXT: bswapq %rdx
279 ; X64-NEXT: cmpq %rdx, %rcx
280 ; X64-NEXT: jne .LBB16_2
281 ; X64-NEXT: # %bb.1: # %loadbb1
282 ; X64-NEXT: movq 8(%rdi), %rcx
283 ; X64-NEXT: movq 8(%rsi), %rdx
284 ; X64-NEXT: bswapq %rcx
285 ; X64-NEXT: bswapq %rdx
286 ; X64-NEXT: xorl %eax, %eax
287 ; X64-NEXT: cmpq %rdx, %rcx
288 ; X64-NEXT: je .LBB16_3
289 ; X64-NEXT: .LBB16_2: # %res_block
290 ; X64-NEXT: xorl %eax, %eax
291 ; X64-NEXT: cmpq %rdx, %rcx
292 ; X64-NEXT: sbbl %eax, %eax
293 ; X64-NEXT: orl $1, %eax
294 ; X64-NEXT: .LBB16_3: # %endblock
296 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 16) nounwind
300 define i1 @length16_eq(ptr %x, ptr %y) nounwind optsize {
301 ; X64-SSE2-LABEL: length16_eq:
303 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
304 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm1
305 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
306 ; X64-SSE2-NEXT: pmovmskb %xmm1, %eax
307 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
308 ; X64-SSE2-NEXT: setne %al
309 ; X64-SSE2-NEXT: retq
311 ; X64-AVX-LABEL: length16_eq:
313 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
314 ; X64-AVX-NEXT: vpxor (%rsi), %xmm0, %xmm0
315 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
316 ; X64-AVX-NEXT: setne %al
318 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 16) nounwind
319 %cmp = icmp ne i32 %call, 0
323 define i1 @length16_eq_const(ptr %X) nounwind optsize {
324 ; X64-SSE2-LABEL: length16_eq_const:
326 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
327 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
328 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
329 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
330 ; X64-SSE2-NEXT: sete %al
331 ; X64-SSE2-NEXT: retq
333 ; X64-AVX-LABEL: length16_eq_const:
335 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
336 ; X64-AVX-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
337 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
338 ; X64-AVX-NEXT: sete %al
340 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 16) nounwind
341 %c = icmp eq i32 %m, 0
345 ; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914
347 define i32 @length24(ptr %X, ptr %Y) nounwind optsize {
348 ; X64-LABEL: length24:
350 ; X64-NEXT: movl $24, %edx
351 ; X64-NEXT: jmp memcmp # TAILCALL
352 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 24) nounwind
356 define i1 @length24_eq(ptr %x, ptr %y) nounwind optsize {
357 ; X64-SSE2-LABEL: length24_eq:
359 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
360 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm1
361 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
362 ; X64-SSE2-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
363 ; X64-SSE2-NEXT: movq {{.*#+}} xmm2 = mem[0],zero
364 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
365 ; X64-SSE2-NEXT: pand %xmm1, %xmm2
366 ; X64-SSE2-NEXT: pmovmskb %xmm2, %eax
367 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
368 ; X64-SSE2-NEXT: sete %al
369 ; X64-SSE2-NEXT: retq
371 ; X64-AVX-LABEL: length24_eq:
373 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
374 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm1 = mem[0],zero
375 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm2 = mem[0],zero
376 ; X64-AVX-NEXT: vpxor %xmm2, %xmm1, %xmm1
377 ; X64-AVX-NEXT: vpxor (%rsi), %xmm0, %xmm0
378 ; X64-AVX-NEXT: vpor %xmm0, %xmm1, %xmm0
379 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
380 ; X64-AVX-NEXT: sete %al
382 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 24) nounwind
383 %cmp = icmp eq i32 %call, 0
387 define i1 @length24_eq_const(ptr %X) nounwind optsize {
388 ; X64-SSE2-LABEL: length24_eq_const:
390 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
391 ; X64-SSE2-NEXT: movq {{.*#+}} xmm1 = mem[0],zero
392 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
393 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
394 ; X64-SSE2-NEXT: pand %xmm1, %xmm0
395 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
396 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
397 ; X64-SSE2-NEXT: setne %al
398 ; X64-SSE2-NEXT: retq
400 ; X64-AVX-LABEL: length24_eq_const:
402 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
403 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm1 = mem[0],zero
404 ; X64-AVX-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
405 ; X64-AVX-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
406 ; X64-AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
407 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
408 ; X64-AVX-NEXT: setne %al
410 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 24) nounwind
411 %c = icmp ne i32 %m, 0
415 define i32 @length32(ptr %X, ptr %Y) nounwind optsize {
416 ; X64-LABEL: length32:
418 ; X64-NEXT: movl $32, %edx
419 ; X64-NEXT: jmp memcmp # TAILCALL
420 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 32) nounwind
424 ; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325
426 define i1 @length32_eq(ptr %x, ptr %y) nounwind optsize {
427 ; X64-SSE2-LABEL: length32_eq:
429 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
430 ; X64-SSE2-NEXT: movdqu 16(%rdi), %xmm1
431 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm2
432 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
433 ; X64-SSE2-NEXT: movdqu 16(%rsi), %xmm0
434 ; X64-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
435 ; X64-SSE2-NEXT: pand %xmm2, %xmm0
436 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
437 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
438 ; X64-SSE2-NEXT: sete %al
439 ; X64-SSE2-NEXT: retq
441 ; X64-AVX1-LABEL: length32_eq:
443 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
444 ; X64-AVX1-NEXT: vxorps (%rsi), %ymm0, %ymm0
445 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
446 ; X64-AVX1-NEXT: sete %al
447 ; X64-AVX1-NEXT: vzeroupper
448 ; X64-AVX1-NEXT: retq
450 ; X64-AVX2-LABEL: length32_eq:
452 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
453 ; X64-AVX2-NEXT: vpxor (%rsi), %ymm0, %ymm0
454 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
455 ; X64-AVX2-NEXT: sete %al
456 ; X64-AVX2-NEXT: vzeroupper
457 ; X64-AVX2-NEXT: retq
458 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 32) nounwind
459 %cmp = icmp eq i32 %call, 0
463 define i1 @length32_eq_const(ptr %X) nounwind optsize {
464 ; X64-SSE2-LABEL: length32_eq_const:
466 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
467 ; X64-SSE2-NEXT: movdqu 16(%rdi), %xmm1
468 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
469 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
470 ; X64-SSE2-NEXT: pand %xmm1, %xmm0
471 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
472 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
473 ; X64-SSE2-NEXT: setne %al
474 ; X64-SSE2-NEXT: retq
476 ; X64-AVX1-LABEL: length32_eq_const:
478 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
479 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
480 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
481 ; X64-AVX1-NEXT: setne %al
482 ; X64-AVX1-NEXT: vzeroupper
483 ; X64-AVX1-NEXT: retq
485 ; X64-AVX2-LABEL: length32_eq_const:
487 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
488 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
489 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
490 ; X64-AVX2-NEXT: setne %al
491 ; X64-AVX2-NEXT: vzeroupper
492 ; X64-AVX2-NEXT: retq
493 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 32) nounwind
494 %c = icmp ne i32 %m, 0
498 define i32 @length64(ptr %X, ptr %Y) nounwind optsize {
499 ; X64-LABEL: length64:
501 ; X64-NEXT: movl $64, %edx
502 ; X64-NEXT: jmp memcmp # TAILCALL
503 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 64) nounwind
507 define i1 @length64_eq(ptr %x, ptr %y) nounwind optsize {
508 ; X64-SSE2-LABEL: length64_eq:
510 ; X64-SSE2-NEXT: pushq %rax
511 ; X64-SSE2-NEXT: movl $64, %edx
512 ; X64-SSE2-NEXT: callq memcmp
513 ; X64-SSE2-NEXT: testl %eax, %eax
514 ; X64-SSE2-NEXT: setne %al
515 ; X64-SSE2-NEXT: popq %rcx
516 ; X64-SSE2-NEXT: retq
518 ; X64-AVX1-LABEL: length64_eq:
520 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
521 ; X64-AVX1-NEXT: vmovups 32(%rdi), %ymm1
522 ; X64-AVX1-NEXT: vxorps 32(%rsi), %ymm1, %ymm1
523 ; X64-AVX1-NEXT: vxorps (%rsi), %ymm0, %ymm0
524 ; X64-AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
525 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
526 ; X64-AVX1-NEXT: setne %al
527 ; X64-AVX1-NEXT: vzeroupper
528 ; X64-AVX1-NEXT: retq
530 ; X64-AVX2-LABEL: length64_eq:
532 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
533 ; X64-AVX2-NEXT: vmovdqu 32(%rdi), %ymm1
534 ; X64-AVX2-NEXT: vpxor 32(%rsi), %ymm1, %ymm1
535 ; X64-AVX2-NEXT: vpxor (%rsi), %ymm0, %ymm0
536 ; X64-AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
537 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
538 ; X64-AVX2-NEXT: setne %al
539 ; X64-AVX2-NEXT: vzeroupper
540 ; X64-AVX2-NEXT: retq
541 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 64) nounwind
542 %cmp = icmp ne i32 %call, 0
546 define i1 @length64_eq_const(ptr %X) nounwind optsize {
547 ; X64-SSE2-LABEL: length64_eq_const:
549 ; X64-SSE2-NEXT: pushq %rax
550 ; X64-SSE2-NEXT: movl $.L.str, %esi
551 ; X64-SSE2-NEXT: movl $64, %edx
552 ; X64-SSE2-NEXT: callq memcmp
553 ; X64-SSE2-NEXT: testl %eax, %eax
554 ; X64-SSE2-NEXT: sete %al
555 ; X64-SSE2-NEXT: popq %rcx
556 ; X64-SSE2-NEXT: retq
558 ; X64-AVX1-LABEL: length64_eq_const:
560 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
561 ; X64-AVX1-NEXT: vmovups 32(%rdi), %ymm1
562 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
563 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
564 ; X64-AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
565 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
566 ; X64-AVX1-NEXT: sete %al
567 ; X64-AVX1-NEXT: vzeroupper
568 ; X64-AVX1-NEXT: retq
570 ; X64-AVX2-LABEL: length64_eq_const:
572 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
573 ; X64-AVX2-NEXT: vmovdqu 32(%rdi), %ymm1
574 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
575 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
576 ; X64-AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
577 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
578 ; X64-AVX2-NEXT: sete %al
579 ; X64-AVX2-NEXT: vzeroupper
580 ; X64-AVX2-NEXT: retq
581 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 64) nounwind
582 %c = icmp eq i32 %m, 0
586 define i32 @bcmp_length2(ptr %X, ptr %Y) nounwind optsize {
587 ; X64-LABEL: bcmp_length2:
589 ; X64-NEXT: movzwl (%rdi), %ecx
590 ; X64-NEXT: xorl %eax, %eax
591 ; X64-NEXT: cmpw (%rsi), %cx
592 ; X64-NEXT: setne %al
594 %m = tail call i32 @bcmp(ptr %X, ptr %Y, i64 2) nounwind