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-prefixes=X64,X64-SSE,X64-SSE2
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=sse4.1 | FileCheck %s --check-prefixes=X64,X64-SSE,X64-SSE41
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s --check-prefixes=X64,X64-AVX,X64-AVX1
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx2 | FileCheck %s --check-prefixes=X64,X64-AVX,X64-AVX2
6 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512bw,+prefer-256-bit | FileCheck %s --check-prefixes=X64,X64-AVX,X64-AVX2
7 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512bw,-prefer-256-bit | FileCheck %s --check-prefixes=X64,X64-AVX,X64-AVX512,X64-AVX512BW
8 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512f,+prefer-256-bit,-prefer-mask-registers | FileCheck %s --check-prefixes=X64,X64-AVX,X64-AVX2
9 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512f,-prefer-256-bit,-prefer-mask-registers | FileCheck %s --check-prefixes=X64,X64-AVX,X64-AVX512,X64-AVX512F
10 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512f,+prefer-256-bit,+prefer-mask-registers | FileCheck %s --check-prefixes=X64,X64-MIC-AVX,X64-MIC-AVX2
11 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx512f,-prefer-256-bit,+prefer-mask-registers | FileCheck %s --check-prefixes=X64,X64-MIC-AVX,X64-MIC-AVX512F
13 ; This tests codegen time inlining/optimization of memcmp
16 @.str = private constant [513 x i8] c"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901\00", align 1
18 declare dso_local i32 @memcmp(ptr, ptr, i64)
20 define i32 @length0(ptr %X, ptr %Y) nounwind {
23 ; X64-NEXT: xorl %eax, %eax
25 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 0) nounwind
29 define i1 @length0_eq(ptr %X, ptr %Y) nounwind {
30 ; X64-LABEL: length0_eq:
32 ; X64-NEXT: movb $1, %al
34 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 0) nounwind
35 %c = icmp eq i32 %m, 0
39 define i1 @length0_lt(ptr %X, ptr %Y) nounwind {
40 ; X64-LABEL: length0_lt:
42 ; X64-NEXT: xorl %eax, %eax
44 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 0) nounwind
45 %c = icmp slt i32 %m, 0
49 define i32 @length2(ptr %X, ptr %Y) nounwind {
52 ; X64-NEXT: movzwl (%rdi), %eax
53 ; X64-NEXT: movzwl (%rsi), %ecx
54 ; X64-NEXT: rolw $8, %ax
55 ; X64-NEXT: rolw $8, %cx
56 ; X64-NEXT: movzwl %ax, %eax
57 ; X64-NEXT: movzwl %cx, %ecx
58 ; X64-NEXT: subl %ecx, %eax
60 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind
64 define i32 @length2_const(ptr %X, ptr %Y) nounwind {
65 ; X64-LABEL: length2_const:
67 ; X64-NEXT: movzwl (%rdi), %eax
68 ; X64-NEXT: rolw $8, %ax
69 ; X64-NEXT: movzwl %ax, %eax
70 ; X64-NEXT: addl $-12594, %eax # imm = 0xCECE
72 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i64 2) nounwind
76 define i1 @length2_gt_const(ptr %X, ptr %Y) nounwind {
77 ; X64-LABEL: length2_gt_const:
79 ; X64-NEXT: movzwl (%rdi), %eax
80 ; X64-NEXT: rolw $8, %ax
81 ; X64-NEXT: movzwl %ax, %eax
82 ; X64-NEXT: addl $-12594, %eax # imm = 0xCECE
83 ; X64-NEXT: testl %eax, %eax
86 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i64 2) nounwind
87 %c = icmp sgt i32 %m, 0
91 define i1 @length2_eq(ptr %X, ptr %Y) nounwind {
92 ; X64-LABEL: length2_eq:
94 ; X64-NEXT: movzwl (%rdi), %eax
95 ; X64-NEXT: cmpw (%rsi), %ax
98 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind
99 %c = icmp eq i32 %m, 0
103 define i1 @length2_lt(ptr %X, ptr %Y) nounwind {
104 ; X64-LABEL: length2_lt:
106 ; X64-NEXT: movzwl (%rdi), %eax
107 ; X64-NEXT: movzwl (%rsi), %ecx
108 ; X64-NEXT: rolw $8, %ax
109 ; X64-NEXT: rolw $8, %cx
110 ; X64-NEXT: movzwl %ax, %eax
111 ; X64-NEXT: movzwl %cx, %ecx
112 ; X64-NEXT: subl %ecx, %eax
113 ; X64-NEXT: shrl $31, %eax
114 ; X64-NEXT: # kill: def $al killed $al killed $eax
116 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind
117 %c = icmp slt i32 %m, 0
121 define i1 @length2_gt(ptr %X, ptr %Y) nounwind {
122 ; X64-LABEL: length2_gt:
124 ; X64-NEXT: movzwl (%rdi), %eax
125 ; X64-NEXT: movzwl (%rsi), %ecx
126 ; X64-NEXT: rolw $8, %ax
127 ; X64-NEXT: rolw $8, %cx
128 ; X64-NEXT: movzwl %ax, %eax
129 ; X64-NEXT: movzwl %cx, %ecx
130 ; X64-NEXT: subl %ecx, %eax
131 ; X64-NEXT: testl %eax, %eax
134 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind
135 %c = icmp sgt i32 %m, 0
139 define i1 @length2_eq_const(ptr %X) nounwind {
140 ; X64-LABEL: length2_eq_const:
142 ; X64-NEXT: movzwl (%rdi), %eax
143 ; X64-NEXT: cmpl $12849, %eax # imm = 0x3231
144 ; X64-NEXT: setne %al
146 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i64 2) nounwind
147 %c = icmp ne i32 %m, 0
151 define i1 @length2_eq_nobuiltin_attr(ptr %X, ptr %Y) nounwind {
152 ; X64-LABEL: length2_eq_nobuiltin_attr:
154 ; X64-NEXT: pushq %rax
155 ; X64-NEXT: movl $2, %edx
156 ; X64-NEXT: callq memcmp
157 ; X64-NEXT: testl %eax, %eax
159 ; X64-NEXT: popq %rcx
161 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind nobuiltin
162 %c = icmp eq i32 %m, 0
166 define i32 @length3(ptr %X, ptr %Y) nounwind {
167 ; X64-LABEL: length3:
169 ; X64-NEXT: movzwl (%rdi), %ecx
170 ; X64-NEXT: movzwl (%rsi), %edx
171 ; X64-NEXT: rolw $8, %cx
172 ; X64-NEXT: rolw $8, %dx
173 ; X64-NEXT: cmpw %dx, %cx
174 ; X64-NEXT: jne .LBB11_3
175 ; X64-NEXT: # %bb.1: # %loadbb1
176 ; X64-NEXT: movzbl 2(%rdi), %eax
177 ; X64-NEXT: movzbl 2(%rsi), %ecx
178 ; X64-NEXT: subl %ecx, %eax
180 ; X64-NEXT: .LBB11_3: # %res_block
181 ; X64-NEXT: xorl %eax, %eax
182 ; X64-NEXT: cmpw %dx, %cx
183 ; X64-NEXT: sbbl %eax, %eax
184 ; X64-NEXT: orl $1, %eax
186 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 3) nounwind
190 define i1 @length3_eq(ptr %X, ptr %Y) nounwind {
191 ; X64-LABEL: length3_eq:
193 ; X64-NEXT: movzwl (%rdi), %eax
194 ; X64-NEXT: xorw (%rsi), %ax
195 ; X64-NEXT: movzbl 2(%rdi), %ecx
196 ; X64-NEXT: xorb 2(%rsi), %cl
197 ; X64-NEXT: movzbl %cl, %ecx
198 ; X64-NEXT: orw %ax, %cx
199 ; X64-NEXT: setne %al
201 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 3) nounwind
202 %c = icmp ne i32 %m, 0
206 define i32 @length4(ptr %X, ptr %Y) nounwind {
207 ; X64-LABEL: length4:
209 ; X64-NEXT: movl (%rdi), %ecx
210 ; X64-NEXT: movl (%rsi), %edx
211 ; X64-NEXT: bswapl %ecx
212 ; X64-NEXT: bswapl %edx
213 ; X64-NEXT: xorl %eax, %eax
214 ; X64-NEXT: cmpl %edx, %ecx
216 ; X64-NEXT: sbbl $0, %eax
218 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 4) nounwind
222 define i1 @length4_eq(ptr %X, ptr %Y) nounwind {
223 ; X64-LABEL: length4_eq:
225 ; X64-NEXT: movl (%rdi), %eax
226 ; X64-NEXT: cmpl (%rsi), %eax
227 ; X64-NEXT: setne %al
229 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 4) nounwind
230 %c = icmp ne i32 %m, 0
234 define i1 @length4_lt(ptr %X, ptr %Y) nounwind {
235 ; X64-LABEL: length4_lt:
237 ; X64-NEXT: movl (%rdi), %ecx
238 ; X64-NEXT: movl (%rsi), %edx
239 ; X64-NEXT: bswapl %ecx
240 ; X64-NEXT: bswapl %edx
241 ; X64-NEXT: xorl %eax, %eax
242 ; X64-NEXT: cmpl %edx, %ecx
244 ; X64-NEXT: sbbl $0, %eax
245 ; X64-NEXT: shrl $31, %eax
246 ; X64-NEXT: # kill: def $al killed $al killed $eax
248 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 4) nounwind
249 %c = icmp slt i32 %m, 0
253 define i1 @length4_gt(ptr %X, ptr %Y) nounwind {
254 ; X64-LABEL: length4_gt:
256 ; X64-NEXT: movl (%rdi), %eax
257 ; X64-NEXT: movl (%rsi), %ecx
258 ; X64-NEXT: bswapl %eax
259 ; X64-NEXT: bswapl %ecx
260 ; X64-NEXT: xorl %edx, %edx
261 ; X64-NEXT: cmpl %ecx, %eax
263 ; X64-NEXT: sbbl $0, %edx
264 ; X64-NEXT: testl %edx, %edx
267 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 4) nounwind
268 %c = icmp sgt i32 %m, 0
272 define i1 @length4_eq_const(ptr %X) nounwind {
273 ; X64-LABEL: length4_eq_const:
275 ; X64-NEXT: cmpl $875770417, (%rdi) # imm = 0x34333231
278 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i64 4) nounwind
279 %c = icmp eq i32 %m, 0
283 define i32 @length5(ptr %X, ptr %Y) nounwind {
284 ; X64-LABEL: length5:
286 ; X64-NEXT: movl (%rdi), %ecx
287 ; X64-NEXT: movl (%rsi), %edx
288 ; X64-NEXT: bswapl %ecx
289 ; X64-NEXT: bswapl %edx
290 ; X64-NEXT: cmpl %edx, %ecx
291 ; X64-NEXT: jne .LBB18_3
292 ; X64-NEXT: # %bb.1: # %loadbb1
293 ; X64-NEXT: movzbl 4(%rdi), %eax
294 ; X64-NEXT: movzbl 4(%rsi), %ecx
295 ; X64-NEXT: subl %ecx, %eax
297 ; X64-NEXT: .LBB18_3: # %res_block
298 ; X64-NEXT: xorl %eax, %eax
299 ; X64-NEXT: cmpl %edx, %ecx
300 ; X64-NEXT: sbbl %eax, %eax
301 ; X64-NEXT: orl $1, %eax
303 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 5) nounwind
307 define i1 @length5_eq(ptr %X, ptr %Y) nounwind {
308 ; X64-LABEL: length5_eq:
310 ; X64-NEXT: movl (%rdi), %eax
311 ; X64-NEXT: xorl (%rsi), %eax
312 ; X64-NEXT: movzbl 4(%rdi), %ecx
313 ; X64-NEXT: xorb 4(%rsi), %cl
314 ; X64-NEXT: movzbl %cl, %ecx
315 ; X64-NEXT: orl %eax, %ecx
316 ; X64-NEXT: setne %al
318 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 5) nounwind
319 %c = icmp ne i32 %m, 0
323 define i1 @length5_lt(ptr %X, ptr %Y) nounwind {
324 ; X64-LABEL: length5_lt:
326 ; X64-NEXT: movl (%rdi), %ecx
327 ; X64-NEXT: movl (%rsi), %edx
328 ; X64-NEXT: bswapl %ecx
329 ; X64-NEXT: bswapl %edx
330 ; X64-NEXT: cmpl %edx, %ecx
331 ; X64-NEXT: jne .LBB20_3
332 ; X64-NEXT: # %bb.1: # %loadbb1
333 ; X64-NEXT: movzbl 4(%rdi), %eax
334 ; X64-NEXT: movzbl 4(%rsi), %ecx
335 ; X64-NEXT: subl %ecx, %eax
336 ; X64-NEXT: shrl $31, %eax
337 ; X64-NEXT: # kill: def $al killed $al killed $eax
339 ; X64-NEXT: .LBB20_3: # %res_block
340 ; X64-NEXT: xorl %eax, %eax
341 ; X64-NEXT: cmpl %edx, %ecx
342 ; X64-NEXT: sbbl %eax, %eax
343 ; X64-NEXT: orl $1, %eax
344 ; X64-NEXT: shrl $31, %eax
345 ; X64-NEXT: # kill: def $al killed $al killed $eax
347 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 5) nounwind
348 %c = icmp slt i32 %m, 0
352 define i32 @length7(ptr %X, ptr %Y) nounwind {
353 ; X64-LABEL: length7:
355 ; X64-NEXT: movl (%rdi), %ecx
356 ; X64-NEXT: movl (%rsi), %edx
357 ; X64-NEXT: bswapl %ecx
358 ; X64-NEXT: bswapl %edx
359 ; X64-NEXT: cmpl %edx, %ecx
360 ; X64-NEXT: jne .LBB21_2
361 ; X64-NEXT: # %bb.1: # %loadbb1
362 ; X64-NEXT: movl 3(%rdi), %ecx
363 ; X64-NEXT: movl 3(%rsi), %edx
364 ; X64-NEXT: bswapl %ecx
365 ; X64-NEXT: bswapl %edx
366 ; X64-NEXT: xorl %eax, %eax
367 ; X64-NEXT: cmpl %edx, %ecx
368 ; X64-NEXT: je .LBB21_3
369 ; X64-NEXT: .LBB21_2: # %res_block
370 ; X64-NEXT: xorl %eax, %eax
371 ; X64-NEXT: cmpl %edx, %ecx
372 ; X64-NEXT: sbbl %eax, %eax
373 ; X64-NEXT: orl $1, %eax
374 ; X64-NEXT: .LBB21_3: # %endblock
376 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 7) nounwind
380 define i1 @length7_lt(ptr %X, ptr %Y) nounwind {
381 ; X64-LABEL: length7_lt:
383 ; X64-NEXT: movl (%rdi), %ecx
384 ; X64-NEXT: movl (%rsi), %edx
385 ; X64-NEXT: bswapl %ecx
386 ; X64-NEXT: bswapl %edx
387 ; X64-NEXT: cmpl %edx, %ecx
388 ; X64-NEXT: jne .LBB22_2
389 ; X64-NEXT: # %bb.1: # %loadbb1
390 ; X64-NEXT: movl 3(%rdi), %ecx
391 ; X64-NEXT: movl 3(%rsi), %edx
392 ; X64-NEXT: bswapl %ecx
393 ; X64-NEXT: bswapl %edx
394 ; X64-NEXT: xorl %eax, %eax
395 ; X64-NEXT: cmpl %edx, %ecx
396 ; X64-NEXT: je .LBB22_3
397 ; X64-NEXT: .LBB22_2: # %res_block
398 ; X64-NEXT: xorl %eax, %eax
399 ; X64-NEXT: cmpl %edx, %ecx
400 ; X64-NEXT: sbbl %eax, %eax
401 ; X64-NEXT: orl $1, %eax
402 ; X64-NEXT: .LBB22_3: # %endblock
403 ; X64-NEXT: shrl $31, %eax
404 ; X64-NEXT: # kill: def $al killed $al killed $eax
406 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 7) nounwind
407 %c = icmp slt i32 %m, 0
411 define i1 @length7_eq(ptr %X, ptr %Y) nounwind {
412 ; X64-LABEL: length7_eq:
414 ; X64-NEXT: movl (%rdi), %eax
415 ; X64-NEXT: movl 3(%rdi), %ecx
416 ; X64-NEXT: xorl (%rsi), %eax
417 ; X64-NEXT: xorl 3(%rsi), %ecx
418 ; X64-NEXT: orl %eax, %ecx
419 ; X64-NEXT: setne %al
421 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 7) nounwind
422 %c = icmp ne i32 %m, 0
426 define i32 @length8(ptr %X, ptr %Y) nounwind {
427 ; X64-LABEL: length8:
429 ; X64-NEXT: movq (%rdi), %rcx
430 ; X64-NEXT: movq (%rsi), %rdx
431 ; X64-NEXT: bswapq %rcx
432 ; X64-NEXT: bswapq %rdx
433 ; X64-NEXT: xorl %eax, %eax
434 ; X64-NEXT: cmpq %rdx, %rcx
436 ; X64-NEXT: sbbl $0, %eax
438 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 8) nounwind
442 define i1 @length8_eq(ptr %X, ptr %Y) nounwind {
443 ; X64-LABEL: length8_eq:
445 ; X64-NEXT: movq (%rdi), %rax
446 ; X64-NEXT: cmpq (%rsi), %rax
449 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 8) nounwind
450 %c = icmp eq i32 %m, 0
454 define i1 @length8_eq_const(ptr %X) nounwind {
455 ; X64-LABEL: length8_eq_const:
457 ; X64-NEXT: movabsq $3978425819141910832, %rax # imm = 0x3736353433323130
458 ; X64-NEXT: cmpq %rax, (%rdi)
459 ; X64-NEXT: setne %al
461 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 8) nounwind
462 %c = icmp ne i32 %m, 0
466 define i1 @length9_eq(ptr %X, ptr %Y) nounwind {
467 ; X64-LABEL: length9_eq:
469 ; X64-NEXT: movq (%rdi), %rax
470 ; X64-NEXT: xorq (%rsi), %rax
471 ; X64-NEXT: movzbl 8(%rdi), %ecx
472 ; X64-NEXT: xorb 8(%rsi), %cl
473 ; X64-NEXT: movzbl %cl, %ecx
474 ; X64-NEXT: orq %rax, %rcx
477 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 9) nounwind
478 %c = icmp eq i32 %m, 0
482 define i1 @length10_eq(ptr %X, ptr %Y) nounwind {
483 ; X64-LABEL: length10_eq:
485 ; X64-NEXT: movq (%rdi), %rax
486 ; X64-NEXT: xorq (%rsi), %rax
487 ; X64-NEXT: movzwl 8(%rdi), %ecx
488 ; X64-NEXT: xorw 8(%rsi), %cx
489 ; X64-NEXT: movzwl %cx, %ecx
490 ; X64-NEXT: orq %rax, %rcx
493 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 10) nounwind
494 %c = icmp eq i32 %m, 0
498 define i1 @length11_eq(ptr %X, ptr %Y) nounwind {
499 ; X64-LABEL: length11_eq:
501 ; X64-NEXT: movq (%rdi), %rax
502 ; X64-NEXT: movq 3(%rdi), %rcx
503 ; X64-NEXT: xorq (%rsi), %rax
504 ; X64-NEXT: xorq 3(%rsi), %rcx
505 ; X64-NEXT: orq %rax, %rcx
508 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 11) nounwind
509 %c = icmp eq i32 %m, 0
513 define i1 @length12_eq(ptr %X, ptr %Y) nounwind {
514 ; X64-LABEL: length12_eq:
516 ; X64-NEXT: movq (%rdi), %rax
517 ; X64-NEXT: xorq (%rsi), %rax
518 ; X64-NEXT: movl 8(%rdi), %ecx
519 ; X64-NEXT: xorl 8(%rsi), %ecx
520 ; X64-NEXT: orq %rax, %rcx
521 ; X64-NEXT: setne %al
523 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 12) nounwind
524 %c = icmp ne i32 %m, 0
528 define i32 @length12(ptr %X, ptr %Y) nounwind {
529 ; X64-LABEL: length12:
531 ; X64-NEXT: movq (%rdi), %rcx
532 ; X64-NEXT: movq (%rsi), %rdx
533 ; X64-NEXT: bswapq %rcx
534 ; X64-NEXT: bswapq %rdx
535 ; X64-NEXT: cmpq %rdx, %rcx
536 ; X64-NEXT: jne .LBB31_2
537 ; X64-NEXT: # %bb.1: # %loadbb1
538 ; X64-NEXT: movl 8(%rdi), %ecx
539 ; X64-NEXT: movl 8(%rsi), %edx
540 ; X64-NEXT: bswapl %ecx
541 ; X64-NEXT: bswapl %edx
542 ; X64-NEXT: xorl %eax, %eax
543 ; X64-NEXT: cmpq %rdx, %rcx
544 ; X64-NEXT: je .LBB31_3
545 ; X64-NEXT: .LBB31_2: # %res_block
546 ; X64-NEXT: xorl %eax, %eax
547 ; X64-NEXT: cmpq %rdx, %rcx
548 ; X64-NEXT: sbbl %eax, %eax
549 ; X64-NEXT: orl $1, %eax
550 ; X64-NEXT: .LBB31_3: # %endblock
552 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 12) nounwind
556 define i1 @length13_eq(ptr %X, ptr %Y) nounwind {
557 ; X64-LABEL: length13_eq:
559 ; X64-NEXT: movq (%rdi), %rax
560 ; X64-NEXT: movq 5(%rdi), %rcx
561 ; X64-NEXT: xorq (%rsi), %rax
562 ; X64-NEXT: xorq 5(%rsi), %rcx
563 ; X64-NEXT: orq %rax, %rcx
566 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 13) nounwind
567 %c = icmp eq i32 %m, 0
571 define i1 @length14_eq(ptr %X, ptr %Y) nounwind {
572 ; X64-LABEL: length14_eq:
574 ; X64-NEXT: movq (%rdi), %rax
575 ; X64-NEXT: movq 6(%rdi), %rcx
576 ; X64-NEXT: xorq (%rsi), %rax
577 ; X64-NEXT: xorq 6(%rsi), %rcx
578 ; X64-NEXT: orq %rax, %rcx
581 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 14) nounwind
582 %c = icmp eq i32 %m, 0
586 define i32 @length15(ptr %X, ptr %Y) nounwind {
587 ; X64-LABEL: length15:
589 ; X64-NEXT: movq (%rdi), %rcx
590 ; X64-NEXT: movq (%rsi), %rdx
591 ; X64-NEXT: bswapq %rcx
592 ; X64-NEXT: bswapq %rdx
593 ; X64-NEXT: cmpq %rdx, %rcx
594 ; X64-NEXT: jne .LBB34_2
595 ; X64-NEXT: # %bb.1: # %loadbb1
596 ; X64-NEXT: movq 7(%rdi), %rcx
597 ; X64-NEXT: movq 7(%rsi), %rdx
598 ; X64-NEXT: bswapq %rcx
599 ; X64-NEXT: bswapq %rdx
600 ; X64-NEXT: xorl %eax, %eax
601 ; X64-NEXT: cmpq %rdx, %rcx
602 ; X64-NEXT: je .LBB34_3
603 ; X64-NEXT: .LBB34_2: # %res_block
604 ; X64-NEXT: xorl %eax, %eax
605 ; X64-NEXT: cmpq %rdx, %rcx
606 ; X64-NEXT: sbbl %eax, %eax
607 ; X64-NEXT: orl $1, %eax
608 ; X64-NEXT: .LBB34_3: # %endblock
610 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 15) nounwind
614 define i1 @length15_lt(ptr %X, ptr %Y) nounwind {
615 ; X64-LABEL: length15_lt:
617 ; X64-NEXT: movq (%rdi), %rcx
618 ; X64-NEXT: movq (%rsi), %rdx
619 ; X64-NEXT: bswapq %rcx
620 ; X64-NEXT: bswapq %rdx
621 ; X64-NEXT: cmpq %rdx, %rcx
622 ; X64-NEXT: jne .LBB35_2
623 ; X64-NEXT: # %bb.1: # %loadbb1
624 ; X64-NEXT: movq 7(%rdi), %rcx
625 ; X64-NEXT: movq 7(%rsi), %rdx
626 ; X64-NEXT: bswapq %rcx
627 ; X64-NEXT: bswapq %rdx
628 ; X64-NEXT: xorl %eax, %eax
629 ; X64-NEXT: cmpq %rdx, %rcx
630 ; X64-NEXT: je .LBB35_3
631 ; X64-NEXT: .LBB35_2: # %res_block
632 ; X64-NEXT: xorl %eax, %eax
633 ; X64-NEXT: cmpq %rdx, %rcx
634 ; X64-NEXT: sbbl %eax, %eax
635 ; X64-NEXT: orl $1, %eax
636 ; X64-NEXT: .LBB35_3: # %endblock
637 ; X64-NEXT: shrl $31, %eax
638 ; X64-NEXT: # kill: def $al killed $al killed $eax
640 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 15) nounwind
641 %c = icmp slt i32 %m, 0
645 define i32 @length15_const(ptr %X, ptr %Y) nounwind {
646 ; X64-LABEL: length15_const:
648 ; X64-NEXT: movabsq $3544952156018063160, %rcx # imm = 0x3132333435363738
649 ; X64-NEXT: movq (%rdi), %rdx
650 ; X64-NEXT: bswapq %rdx
651 ; X64-NEXT: cmpq %rcx, %rdx
652 ; X64-NEXT: jne .LBB36_2
653 ; X64-NEXT: # %bb.1: # %loadbb1
654 ; X64-NEXT: movabsq $4051322327650219061, %rcx # imm = 0x3839303132333435
655 ; X64-NEXT: movq 7(%rdi), %rdx
656 ; X64-NEXT: bswapq %rdx
657 ; X64-NEXT: xorl %eax, %eax
658 ; X64-NEXT: cmpq %rcx, %rdx
659 ; X64-NEXT: je .LBB36_3
660 ; X64-NEXT: .LBB36_2: # %res_block
661 ; X64-NEXT: xorl %eax, %eax
662 ; X64-NEXT: cmpq %rcx, %rdx
663 ; X64-NEXT: sbbl %eax, %eax
664 ; X64-NEXT: orl $1, %eax
665 ; X64-NEXT: .LBB36_3: # %endblock
667 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i64 15) nounwind
671 define i1 @length15_eq(ptr %X, ptr %Y) nounwind {
672 ; X64-LABEL: length15_eq:
674 ; X64-NEXT: movq (%rdi), %rax
675 ; X64-NEXT: movq 7(%rdi), %rcx
676 ; X64-NEXT: xorq (%rsi), %rax
677 ; X64-NEXT: xorq 7(%rsi), %rcx
678 ; X64-NEXT: orq %rax, %rcx
681 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 15) nounwind
682 %c = icmp eq i32 %m, 0
686 define i1 @length15_gt_const(ptr %X, ptr %Y) nounwind {
687 ; X64-LABEL: length15_gt_const:
689 ; X64-NEXT: movabsq $3544952156018063160, %rax # imm = 0x3132333435363738
690 ; X64-NEXT: movq (%rdi), %rcx
691 ; X64-NEXT: bswapq %rcx
692 ; X64-NEXT: cmpq %rax, %rcx
693 ; X64-NEXT: jne .LBB38_2
694 ; X64-NEXT: # %bb.1: # %loadbb1
695 ; X64-NEXT: movabsq $4051322327650219061, %rax # imm = 0x3839303132333435
696 ; X64-NEXT: movq 7(%rdi), %rcx
697 ; X64-NEXT: bswapq %rcx
698 ; X64-NEXT: xorl %edx, %edx
699 ; X64-NEXT: cmpq %rax, %rcx
700 ; X64-NEXT: je .LBB38_3
701 ; X64-NEXT: .LBB38_2: # %res_block
702 ; X64-NEXT: xorl %edx, %edx
703 ; X64-NEXT: cmpq %rax, %rcx
704 ; X64-NEXT: sbbl %edx, %edx
705 ; X64-NEXT: orl $1, %edx
706 ; X64-NEXT: .LBB38_3: # %endblock
707 ; X64-NEXT: testl %edx, %edx
710 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i64 15) nounwind
711 %c = icmp sgt i32 %m, 0
715 ; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329
717 define i32 @length16(ptr %X, ptr %Y) nounwind {
718 ; X64-LABEL: length16:
720 ; X64-NEXT: movq (%rdi), %rcx
721 ; X64-NEXT: movq (%rsi), %rdx
722 ; X64-NEXT: bswapq %rcx
723 ; X64-NEXT: bswapq %rdx
724 ; X64-NEXT: cmpq %rdx, %rcx
725 ; X64-NEXT: jne .LBB39_2
726 ; X64-NEXT: # %bb.1: # %loadbb1
727 ; X64-NEXT: movq 8(%rdi), %rcx
728 ; X64-NEXT: movq 8(%rsi), %rdx
729 ; X64-NEXT: bswapq %rcx
730 ; X64-NEXT: bswapq %rdx
731 ; X64-NEXT: xorl %eax, %eax
732 ; X64-NEXT: cmpq %rdx, %rcx
733 ; X64-NEXT: je .LBB39_3
734 ; X64-NEXT: .LBB39_2: # %res_block
735 ; X64-NEXT: xorl %eax, %eax
736 ; X64-NEXT: cmpq %rdx, %rcx
737 ; X64-NEXT: sbbl %eax, %eax
738 ; X64-NEXT: orl $1, %eax
739 ; X64-NEXT: .LBB39_3: # %endblock
741 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 16) nounwind
745 define i1 @length16_eq(ptr %x, ptr %y) nounwind {
746 ; X64-SSE2-LABEL: length16_eq:
748 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
749 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm1
750 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
751 ; X64-SSE2-NEXT: pmovmskb %xmm1, %eax
752 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
753 ; X64-SSE2-NEXT: setne %al
754 ; X64-SSE2-NEXT: retq
756 ; X64-SSE41-LABEL: length16_eq:
757 ; X64-SSE41: # %bb.0:
758 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
759 ; X64-SSE41-NEXT: movdqu (%rsi), %xmm1
760 ; X64-SSE41-NEXT: pxor %xmm0, %xmm1
761 ; X64-SSE41-NEXT: ptest %xmm1, %xmm1
762 ; X64-SSE41-NEXT: setne %al
763 ; X64-SSE41-NEXT: retq
765 ; X64-AVX-LABEL: length16_eq:
767 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
768 ; X64-AVX-NEXT: vpxor (%rsi), %xmm0, %xmm0
769 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
770 ; X64-AVX-NEXT: setne %al
773 ; X64-MIC-AVX-LABEL: length16_eq:
774 ; X64-MIC-AVX: # %bb.0:
775 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %xmm0
776 ; X64-MIC-AVX-NEXT: vmovdqu (%rsi), %xmm1
777 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k0
778 ; X64-MIC-AVX-NEXT: kortestw %k0, %k0
779 ; X64-MIC-AVX-NEXT: setne %al
780 ; X64-MIC-AVX-NEXT: vzeroupper
781 ; X64-MIC-AVX-NEXT: retq
782 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 16) nounwind
783 %cmp = icmp ne i32 %call, 0
787 define i1 @length16_lt(ptr %x, ptr %y) nounwind {
788 ; X64-LABEL: length16_lt:
790 ; X64-NEXT: movq (%rdi), %rcx
791 ; X64-NEXT: movq (%rsi), %rdx
792 ; X64-NEXT: bswapq %rcx
793 ; X64-NEXT: bswapq %rdx
794 ; X64-NEXT: cmpq %rdx, %rcx
795 ; X64-NEXT: jne .LBB41_2
796 ; X64-NEXT: # %bb.1: # %loadbb1
797 ; X64-NEXT: movq 8(%rdi), %rcx
798 ; X64-NEXT: movq 8(%rsi), %rdx
799 ; X64-NEXT: bswapq %rcx
800 ; X64-NEXT: bswapq %rdx
801 ; X64-NEXT: xorl %eax, %eax
802 ; X64-NEXT: cmpq %rdx, %rcx
803 ; X64-NEXT: je .LBB41_3
804 ; X64-NEXT: .LBB41_2: # %res_block
805 ; X64-NEXT: xorl %eax, %eax
806 ; X64-NEXT: cmpq %rdx, %rcx
807 ; X64-NEXT: sbbl %eax, %eax
808 ; X64-NEXT: orl $1, %eax
809 ; X64-NEXT: .LBB41_3: # %endblock
810 ; X64-NEXT: shrl $31, %eax
811 ; X64-NEXT: # kill: def $al killed $al killed $eax
813 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 16) nounwind
814 %cmp = icmp slt i32 %call, 0
818 define i1 @length16_gt(ptr %x, ptr %y) nounwind {
819 ; X64-LABEL: length16_gt:
821 ; X64-NEXT: movq (%rdi), %rax
822 ; X64-NEXT: movq (%rsi), %rcx
823 ; X64-NEXT: bswapq %rax
824 ; X64-NEXT: bswapq %rcx
825 ; X64-NEXT: cmpq %rcx, %rax
826 ; X64-NEXT: jne .LBB42_2
827 ; X64-NEXT: # %bb.1: # %loadbb1
828 ; X64-NEXT: movq 8(%rdi), %rax
829 ; X64-NEXT: movq 8(%rsi), %rcx
830 ; X64-NEXT: bswapq %rax
831 ; X64-NEXT: bswapq %rcx
832 ; X64-NEXT: xorl %edx, %edx
833 ; X64-NEXT: cmpq %rcx, %rax
834 ; X64-NEXT: je .LBB42_3
835 ; X64-NEXT: .LBB42_2: # %res_block
836 ; X64-NEXT: xorl %edx, %edx
837 ; X64-NEXT: cmpq %rcx, %rax
838 ; X64-NEXT: sbbl %edx, %edx
839 ; X64-NEXT: orl $1, %edx
840 ; X64-NEXT: .LBB42_3: # %endblock
841 ; X64-NEXT: testl %edx, %edx
844 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 16) nounwind
845 %cmp = icmp sgt i32 %call, 0
849 define i1 @length16_eq_const(ptr %X) nounwind {
850 ; X64-SSE2-LABEL: length16_eq_const:
852 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
853 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
854 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
855 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
856 ; X64-SSE2-NEXT: sete %al
857 ; X64-SSE2-NEXT: retq
859 ; X64-SSE41-LABEL: length16_eq_const:
860 ; X64-SSE41: # %bb.0:
861 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
862 ; X64-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
863 ; X64-SSE41-NEXT: ptest %xmm0, %xmm0
864 ; X64-SSE41-NEXT: sete %al
865 ; X64-SSE41-NEXT: retq
867 ; X64-AVX-LABEL: length16_eq_const:
869 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
870 ; X64-AVX-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
871 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
872 ; X64-AVX-NEXT: sete %al
875 ; X64-MIC-AVX-LABEL: length16_eq_const:
876 ; X64-MIC-AVX: # %bb.0:
877 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %xmm0
878 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} xmm1 = [858927408,926299444,825243960,892613426]
879 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k0
880 ; X64-MIC-AVX-NEXT: kortestw %k0, %k0
881 ; X64-MIC-AVX-NEXT: sete %al
882 ; X64-MIC-AVX-NEXT: vzeroupper
883 ; X64-MIC-AVX-NEXT: retq
884 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 16) nounwind
885 %c = icmp eq i32 %m, 0
889 ; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914
891 define i32 @length24(ptr %X, ptr %Y) nounwind {
892 ; X64-LABEL: length24:
894 ; X64-NEXT: movl $24, %edx
895 ; X64-NEXT: jmp memcmp # TAILCALL
896 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 24) nounwind
900 define i1 @length24_eq(ptr %x, ptr %y) nounwind {
901 ; X64-SSE2-LABEL: length24_eq:
903 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
904 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm1
905 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
906 ; X64-SSE2-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
907 ; X64-SSE2-NEXT: movq {{.*#+}} xmm2 = mem[0],zero
908 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
909 ; X64-SSE2-NEXT: pand %xmm1, %xmm2
910 ; X64-SSE2-NEXT: pmovmskb %xmm2, %eax
911 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
912 ; X64-SSE2-NEXT: sete %al
913 ; X64-SSE2-NEXT: retq
915 ; X64-SSE41-LABEL: length24_eq:
916 ; X64-SSE41: # %bb.0:
917 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
918 ; X64-SSE41-NEXT: movdqu (%rsi), %xmm1
919 ; X64-SSE41-NEXT: pxor %xmm0, %xmm1
920 ; X64-SSE41-NEXT: movq {{.*#+}} xmm0 = mem[0],zero
921 ; X64-SSE41-NEXT: movq {{.*#+}} xmm2 = mem[0],zero
922 ; X64-SSE41-NEXT: pxor %xmm0, %xmm2
923 ; X64-SSE41-NEXT: por %xmm1, %xmm2
924 ; X64-SSE41-NEXT: ptest %xmm2, %xmm2
925 ; X64-SSE41-NEXT: sete %al
926 ; X64-SSE41-NEXT: retq
928 ; X64-AVX-LABEL: length24_eq:
930 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
931 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm1 = mem[0],zero
932 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm2 = mem[0],zero
933 ; X64-AVX-NEXT: vpxor %xmm2, %xmm1, %xmm1
934 ; X64-AVX-NEXT: vpxor (%rsi), %xmm0, %xmm0
935 ; X64-AVX-NEXT: vpor %xmm0, %xmm1, %xmm0
936 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
937 ; X64-AVX-NEXT: sete %al
940 ; X64-MIC-AVX-LABEL: length24_eq:
941 ; X64-MIC-AVX: # %bb.0:
942 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %xmm0
943 ; X64-MIC-AVX-NEXT: vmovdqu (%rsi), %xmm1
944 ; X64-MIC-AVX-NEXT: vmovq {{.*#+}} xmm2 = mem[0],zero
945 ; X64-MIC-AVX-NEXT: vmovq {{.*#+}} xmm3 = mem[0],zero
946 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm3, %zmm2, %k0
947 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k1
948 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
949 ; X64-MIC-AVX-NEXT: sete %al
950 ; X64-MIC-AVX-NEXT: vzeroupper
951 ; X64-MIC-AVX-NEXT: retq
952 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 24) nounwind
953 %cmp = icmp eq i32 %call, 0
957 define i1 @length24_lt(ptr %x, ptr %y) nounwind {
958 ; X64-LABEL: length24_lt:
960 ; X64-NEXT: pushq %rax
961 ; X64-NEXT: movl $24, %edx
962 ; X64-NEXT: callq memcmp
963 ; X64-NEXT: shrl $31, %eax
964 ; X64-NEXT: # kill: def $al killed $al killed $eax
965 ; X64-NEXT: popq %rcx
967 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 24) nounwind
968 %cmp = icmp slt i32 %call, 0
972 define i1 @length24_gt(ptr %x, ptr %y) nounwind {
973 ; X64-LABEL: length24_gt:
975 ; X64-NEXT: pushq %rax
976 ; X64-NEXT: movl $24, %edx
977 ; X64-NEXT: callq memcmp
978 ; X64-NEXT: testl %eax, %eax
980 ; X64-NEXT: popq %rcx
982 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 24) nounwind
983 %cmp = icmp sgt i32 %call, 0
987 define i1 @length24_eq_const(ptr %X) nounwind {
988 ; X64-SSE2-LABEL: length24_eq_const:
990 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
991 ; X64-SSE2-NEXT: movq {{.*#+}} xmm1 = mem[0],zero
992 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
993 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
994 ; X64-SSE2-NEXT: pand %xmm1, %xmm0
995 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
996 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
997 ; X64-SSE2-NEXT: setne %al
998 ; X64-SSE2-NEXT: retq
1000 ; X64-SSE41-LABEL: length24_eq_const:
1001 ; X64-SSE41: # %bb.0:
1002 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
1003 ; X64-SSE41-NEXT: movq {{.*#+}} xmm1 = mem[0],zero
1004 ; X64-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
1005 ; X64-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1006 ; X64-SSE41-NEXT: por %xmm1, %xmm0
1007 ; X64-SSE41-NEXT: ptest %xmm0, %xmm0
1008 ; X64-SSE41-NEXT: setne %al
1009 ; X64-SSE41-NEXT: retq
1011 ; X64-AVX-LABEL: length24_eq_const:
1013 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1014 ; X64-AVX-NEXT: vmovq {{.*#+}} xmm1 = mem[0],zero
1015 ; X64-AVX-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
1016 ; X64-AVX-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1017 ; X64-AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
1018 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
1019 ; X64-AVX-NEXT: setne %al
1020 ; X64-AVX-NEXT: retq
1022 ; X64-MIC-AVX-LABEL: length24_eq_const:
1023 ; X64-MIC-AVX: # %bb.0:
1024 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %xmm0
1025 ; X64-MIC-AVX-NEXT: vmovq {{.*#+}} xmm1 = mem[0],zero
1026 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} xmm2 = [959985462,858927408,0,0]
1027 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm2, %zmm1, %k0
1028 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} xmm1 = [858927408,926299444,825243960,892613426]
1029 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k1
1030 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1031 ; X64-MIC-AVX-NEXT: setne %al
1032 ; X64-MIC-AVX-NEXT: vzeroupper
1033 ; X64-MIC-AVX-NEXT: retq
1034 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 24) nounwind
1035 %c = icmp ne i32 %m, 0
1039 define i32 @length31(ptr %X, ptr %Y) nounwind {
1040 ; X64-LABEL: length31:
1042 ; X64-NEXT: movl $31, %edx
1043 ; X64-NEXT: jmp memcmp # TAILCALL
1044 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 31) nounwind
1048 define i1 @length31_eq(ptr %x, ptr %y) nounwind {
1049 ; X64-SSE2-LABEL: length31_eq:
1050 ; X64-SSE2: # %bb.0:
1051 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1052 ; X64-SSE2-NEXT: movdqu 15(%rdi), %xmm1
1053 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm2
1054 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
1055 ; X64-SSE2-NEXT: movdqu 15(%rsi), %xmm0
1056 ; X64-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
1057 ; X64-SSE2-NEXT: pand %xmm2, %xmm0
1058 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1059 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1060 ; X64-SSE2-NEXT: sete %al
1061 ; X64-SSE2-NEXT: retq
1063 ; X64-SSE41-LABEL: length31_eq:
1064 ; X64-SSE41: # %bb.0:
1065 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
1066 ; X64-SSE41-NEXT: movdqu 15(%rdi), %xmm1
1067 ; X64-SSE41-NEXT: movdqu (%rsi), %xmm2
1068 ; X64-SSE41-NEXT: pxor %xmm0, %xmm2
1069 ; X64-SSE41-NEXT: movdqu 15(%rsi), %xmm0
1070 ; X64-SSE41-NEXT: pxor %xmm1, %xmm0
1071 ; X64-SSE41-NEXT: por %xmm2, %xmm0
1072 ; X64-SSE41-NEXT: ptest %xmm0, %xmm0
1073 ; X64-SSE41-NEXT: sete %al
1074 ; X64-SSE41-NEXT: retq
1076 ; X64-AVX-LABEL: length31_eq:
1078 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1079 ; X64-AVX-NEXT: vmovdqu 15(%rdi), %xmm1
1080 ; X64-AVX-NEXT: vpxor 15(%rsi), %xmm1, %xmm1
1081 ; X64-AVX-NEXT: vpxor (%rsi), %xmm0, %xmm0
1082 ; X64-AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
1083 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
1084 ; X64-AVX-NEXT: sete %al
1085 ; X64-AVX-NEXT: retq
1087 ; X64-MIC-AVX-LABEL: length31_eq:
1088 ; X64-MIC-AVX: # %bb.0:
1089 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %xmm0
1090 ; X64-MIC-AVX-NEXT: vmovdqu 15(%rdi), %xmm1
1091 ; X64-MIC-AVX-NEXT: vmovdqu (%rsi), %xmm2
1092 ; X64-MIC-AVX-NEXT: vmovdqu 15(%rsi), %xmm3
1093 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm3, %zmm1, %k0
1094 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm2, %zmm0, %k1
1095 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1096 ; X64-MIC-AVX-NEXT: sete %al
1097 ; X64-MIC-AVX-NEXT: vzeroupper
1098 ; X64-MIC-AVX-NEXT: retq
1099 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 31) nounwind
1100 %cmp = icmp eq i32 %call, 0
1104 define i1 @length31_lt(ptr %x, ptr %y) nounwind {
1105 ; X64-LABEL: length31_lt:
1107 ; X64-NEXT: pushq %rax
1108 ; X64-NEXT: movl $31, %edx
1109 ; X64-NEXT: callq memcmp
1110 ; X64-NEXT: shrl $31, %eax
1111 ; X64-NEXT: # kill: def $al killed $al killed $eax
1112 ; X64-NEXT: popq %rcx
1114 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 31) nounwind
1115 %cmp = icmp slt i32 %call, 0
1119 define i1 @length31_gt(ptr %x, ptr %y) nounwind {
1120 ; X64-LABEL: length31_gt:
1122 ; X64-NEXT: pushq %rax
1123 ; X64-NEXT: movl $31, %edx
1124 ; X64-NEXT: callq memcmp
1125 ; X64-NEXT: testl %eax, %eax
1126 ; X64-NEXT: setg %al
1127 ; X64-NEXT: popq %rcx
1129 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 31) nounwind
1130 %cmp = icmp sgt i32 %call, 0
1134 define i1 @length31_eq_prefer128(ptr %x, ptr %y) nounwind "prefer-vector-width"="128" {
1135 ; X64-SSE2-LABEL: length31_eq_prefer128:
1136 ; X64-SSE2: # %bb.0:
1137 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1138 ; X64-SSE2-NEXT: movdqu 15(%rdi), %xmm1
1139 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm2
1140 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
1141 ; X64-SSE2-NEXT: movdqu 15(%rsi), %xmm0
1142 ; X64-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
1143 ; X64-SSE2-NEXT: pand %xmm2, %xmm0
1144 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1145 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1146 ; X64-SSE2-NEXT: sete %al
1147 ; X64-SSE2-NEXT: retq
1149 ; X64-SSE41-LABEL: length31_eq_prefer128:
1150 ; X64-SSE41: # %bb.0:
1151 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
1152 ; X64-SSE41-NEXT: movdqu 15(%rdi), %xmm1
1153 ; X64-SSE41-NEXT: movdqu (%rsi), %xmm2
1154 ; X64-SSE41-NEXT: pxor %xmm0, %xmm2
1155 ; X64-SSE41-NEXT: movdqu 15(%rsi), %xmm0
1156 ; X64-SSE41-NEXT: pxor %xmm1, %xmm0
1157 ; X64-SSE41-NEXT: por %xmm2, %xmm0
1158 ; X64-SSE41-NEXT: ptest %xmm0, %xmm0
1159 ; X64-SSE41-NEXT: sete %al
1160 ; X64-SSE41-NEXT: retq
1162 ; X64-AVX-LABEL: length31_eq_prefer128:
1164 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1165 ; X64-AVX-NEXT: vmovdqu 15(%rdi), %xmm1
1166 ; X64-AVX-NEXT: vpxor 15(%rsi), %xmm1, %xmm1
1167 ; X64-AVX-NEXT: vpxor (%rsi), %xmm0, %xmm0
1168 ; X64-AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
1169 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
1170 ; X64-AVX-NEXT: sete %al
1171 ; X64-AVX-NEXT: retq
1173 ; X64-MIC-AVX-LABEL: length31_eq_prefer128:
1174 ; X64-MIC-AVX: # %bb.0:
1175 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %xmm0
1176 ; X64-MIC-AVX-NEXT: vmovdqu 15(%rdi), %xmm1
1177 ; X64-MIC-AVX-NEXT: vmovdqu (%rsi), %xmm2
1178 ; X64-MIC-AVX-NEXT: vmovdqu 15(%rsi), %xmm3
1179 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm3, %zmm1, %k0
1180 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm2, %zmm0, %k1
1181 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1182 ; X64-MIC-AVX-NEXT: sete %al
1183 ; X64-MIC-AVX-NEXT: vzeroupper
1184 ; X64-MIC-AVX-NEXT: retq
1185 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 31) nounwind
1186 %cmp = icmp eq i32 %call, 0
1190 define i1 @length31_eq_const(ptr %X) nounwind {
1191 ; X64-SSE2-LABEL: length31_eq_const:
1192 ; X64-SSE2: # %bb.0:
1193 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1194 ; X64-SSE2-NEXT: movdqu 15(%rdi), %xmm1
1195 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
1196 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1197 ; X64-SSE2-NEXT: pand %xmm1, %xmm0
1198 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1199 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1200 ; X64-SSE2-NEXT: setne %al
1201 ; X64-SSE2-NEXT: retq
1203 ; X64-SSE41-LABEL: length31_eq_const:
1204 ; X64-SSE41: # %bb.0:
1205 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
1206 ; X64-SSE41-NEXT: movdqu 15(%rdi), %xmm1
1207 ; X64-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
1208 ; X64-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1209 ; X64-SSE41-NEXT: por %xmm1, %xmm0
1210 ; X64-SSE41-NEXT: ptest %xmm0, %xmm0
1211 ; X64-SSE41-NEXT: setne %al
1212 ; X64-SSE41-NEXT: retq
1214 ; X64-AVX-LABEL: length31_eq_const:
1216 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1217 ; X64-AVX-NEXT: vmovdqu 15(%rdi), %xmm1
1218 ; X64-AVX-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1, %xmm1
1219 ; X64-AVX-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0
1220 ; X64-AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
1221 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
1222 ; X64-AVX-NEXT: setne %al
1223 ; X64-AVX-NEXT: retq
1225 ; X64-MIC-AVX-LABEL: length31_eq_const:
1226 ; X64-MIC-AVX: # %bb.0:
1227 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %xmm0
1228 ; X64-MIC-AVX-NEXT: vmovdqu 15(%rdi), %xmm1
1229 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} xmm2 = [943142453,842084409,909456435,809056311]
1230 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm2, %zmm1, %k0
1231 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} xmm1 = [858927408,926299444,825243960,892613426]
1232 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k1
1233 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1234 ; X64-MIC-AVX-NEXT: setne %al
1235 ; X64-MIC-AVX-NEXT: vzeroupper
1236 ; X64-MIC-AVX-NEXT: retq
1237 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 31) nounwind
1238 %c = icmp ne i32 %m, 0
1242 define i32 @length32(ptr %X, ptr %Y) nounwind {
1243 ; X64-LABEL: length32:
1245 ; X64-NEXT: movl $32, %edx
1246 ; X64-NEXT: jmp memcmp # TAILCALL
1247 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 32) nounwind
1251 ; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325
1253 define i1 @length32_eq(ptr %x, ptr %y) nounwind {
1254 ; X64-SSE2-LABEL: length32_eq:
1255 ; X64-SSE2: # %bb.0:
1256 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1257 ; X64-SSE2-NEXT: movdqu 16(%rdi), %xmm1
1258 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm2
1259 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
1260 ; X64-SSE2-NEXT: movdqu 16(%rsi), %xmm0
1261 ; X64-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
1262 ; X64-SSE2-NEXT: pand %xmm2, %xmm0
1263 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1264 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1265 ; X64-SSE2-NEXT: sete %al
1266 ; X64-SSE2-NEXT: retq
1268 ; X64-SSE41-LABEL: length32_eq:
1269 ; X64-SSE41: # %bb.0:
1270 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
1271 ; X64-SSE41-NEXT: movdqu 16(%rdi), %xmm1
1272 ; X64-SSE41-NEXT: movdqu (%rsi), %xmm2
1273 ; X64-SSE41-NEXT: pxor %xmm0, %xmm2
1274 ; X64-SSE41-NEXT: movdqu 16(%rsi), %xmm0
1275 ; X64-SSE41-NEXT: pxor %xmm1, %xmm0
1276 ; X64-SSE41-NEXT: por %xmm2, %xmm0
1277 ; X64-SSE41-NEXT: ptest %xmm0, %xmm0
1278 ; X64-SSE41-NEXT: sete %al
1279 ; X64-SSE41-NEXT: retq
1281 ; X64-AVX1-LABEL: length32_eq:
1282 ; X64-AVX1: # %bb.0:
1283 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
1284 ; X64-AVX1-NEXT: vxorps (%rsi), %ymm0, %ymm0
1285 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
1286 ; X64-AVX1-NEXT: sete %al
1287 ; X64-AVX1-NEXT: vzeroupper
1288 ; X64-AVX1-NEXT: retq
1290 ; X64-AVX2-LABEL: length32_eq:
1291 ; X64-AVX2: # %bb.0:
1292 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1293 ; X64-AVX2-NEXT: vpxor (%rsi), %ymm0, %ymm0
1294 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
1295 ; X64-AVX2-NEXT: sete %al
1296 ; X64-AVX2-NEXT: vzeroupper
1297 ; X64-AVX2-NEXT: retq
1299 ; X64-AVX512-LABEL: length32_eq:
1300 ; X64-AVX512: # %bb.0:
1301 ; X64-AVX512-NEXT: vmovdqu (%rdi), %ymm0
1302 ; X64-AVX512-NEXT: vpxor (%rsi), %ymm0, %ymm0
1303 ; X64-AVX512-NEXT: vptest %ymm0, %ymm0
1304 ; X64-AVX512-NEXT: sete %al
1305 ; X64-AVX512-NEXT: vzeroupper
1306 ; X64-AVX512-NEXT: retq
1308 ; X64-MIC-AVX-LABEL: length32_eq:
1309 ; X64-MIC-AVX: # %bb.0:
1310 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %ymm0
1311 ; X64-MIC-AVX-NEXT: vmovdqu (%rsi), %ymm1
1312 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k0
1313 ; X64-MIC-AVX-NEXT: kortestw %k0, %k0
1314 ; X64-MIC-AVX-NEXT: sete %al
1315 ; X64-MIC-AVX-NEXT: vzeroupper
1316 ; X64-MIC-AVX-NEXT: retq
1317 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 32) nounwind
1318 %cmp = icmp eq i32 %call, 0
1322 define i1 @length32_lt(ptr %x, ptr %y) nounwind {
1323 ; X64-LABEL: length32_lt:
1325 ; X64-NEXT: pushq %rax
1326 ; X64-NEXT: movl $32, %edx
1327 ; X64-NEXT: callq memcmp
1328 ; X64-NEXT: shrl $31, %eax
1329 ; X64-NEXT: # kill: def $al killed $al killed $eax
1330 ; X64-NEXT: popq %rcx
1332 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 32) nounwind
1333 %cmp = icmp slt i32 %call, 0
1337 define i1 @length32_gt(ptr %x, ptr %y) nounwind {
1338 ; X64-LABEL: length32_gt:
1340 ; X64-NEXT: pushq %rax
1341 ; X64-NEXT: movl $32, %edx
1342 ; X64-NEXT: callq memcmp
1343 ; X64-NEXT: testl %eax, %eax
1344 ; X64-NEXT: setg %al
1345 ; X64-NEXT: popq %rcx
1347 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 32) nounwind
1348 %cmp = icmp sgt i32 %call, 0
1352 define i1 @length32_eq_prefer128(ptr %x, ptr %y) nounwind "prefer-vector-width"="128" {
1353 ; X64-SSE2-LABEL: length32_eq_prefer128:
1354 ; X64-SSE2: # %bb.0:
1355 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1356 ; X64-SSE2-NEXT: movdqu 16(%rdi), %xmm1
1357 ; X64-SSE2-NEXT: movdqu (%rsi), %xmm2
1358 ; X64-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
1359 ; X64-SSE2-NEXT: movdqu 16(%rsi), %xmm0
1360 ; X64-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
1361 ; X64-SSE2-NEXT: pand %xmm2, %xmm0
1362 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1363 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1364 ; X64-SSE2-NEXT: sete %al
1365 ; X64-SSE2-NEXT: retq
1367 ; X64-SSE41-LABEL: length32_eq_prefer128:
1368 ; X64-SSE41: # %bb.0:
1369 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
1370 ; X64-SSE41-NEXT: movdqu 16(%rdi), %xmm1
1371 ; X64-SSE41-NEXT: movdqu (%rsi), %xmm2
1372 ; X64-SSE41-NEXT: pxor %xmm0, %xmm2
1373 ; X64-SSE41-NEXT: movdqu 16(%rsi), %xmm0
1374 ; X64-SSE41-NEXT: pxor %xmm1, %xmm0
1375 ; X64-SSE41-NEXT: por %xmm2, %xmm0
1376 ; X64-SSE41-NEXT: ptest %xmm0, %xmm0
1377 ; X64-SSE41-NEXT: sete %al
1378 ; X64-SSE41-NEXT: retq
1380 ; X64-AVX-LABEL: length32_eq_prefer128:
1382 ; X64-AVX-NEXT: vmovdqu (%rdi), %xmm0
1383 ; X64-AVX-NEXT: vmovdqu 16(%rdi), %xmm1
1384 ; X64-AVX-NEXT: vpxor 16(%rsi), %xmm1, %xmm1
1385 ; X64-AVX-NEXT: vpxor (%rsi), %xmm0, %xmm0
1386 ; X64-AVX-NEXT: vpor %xmm1, %xmm0, %xmm0
1387 ; X64-AVX-NEXT: vptest %xmm0, %xmm0
1388 ; X64-AVX-NEXT: sete %al
1389 ; X64-AVX-NEXT: retq
1391 ; X64-MIC-AVX-LABEL: length32_eq_prefer128:
1392 ; X64-MIC-AVX: # %bb.0:
1393 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %xmm0
1394 ; X64-MIC-AVX-NEXT: vmovdqu 16(%rdi), %xmm1
1395 ; X64-MIC-AVX-NEXT: vmovdqu (%rsi), %xmm2
1396 ; X64-MIC-AVX-NEXT: vmovdqu 16(%rsi), %xmm3
1397 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm3, %zmm1, %k0
1398 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm2, %zmm0, %k1
1399 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1400 ; X64-MIC-AVX-NEXT: sete %al
1401 ; X64-MIC-AVX-NEXT: vzeroupper
1402 ; X64-MIC-AVX-NEXT: retq
1403 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 32) nounwind
1404 %cmp = icmp eq i32 %call, 0
1408 define i1 @length32_eq_const(ptr %X) nounwind {
1409 ; X64-SSE2-LABEL: length32_eq_const:
1410 ; X64-SSE2: # %bb.0:
1411 ; X64-SSE2-NEXT: movdqu (%rdi), %xmm0
1412 ; X64-SSE2-NEXT: movdqu 16(%rdi), %xmm1
1413 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
1414 ; X64-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1415 ; X64-SSE2-NEXT: pand %xmm1, %xmm0
1416 ; X64-SSE2-NEXT: pmovmskb %xmm0, %eax
1417 ; X64-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
1418 ; X64-SSE2-NEXT: setne %al
1419 ; X64-SSE2-NEXT: retq
1421 ; X64-SSE41-LABEL: length32_eq_const:
1422 ; X64-SSE41: # %bb.0:
1423 ; X64-SSE41-NEXT: movdqu (%rdi), %xmm0
1424 ; X64-SSE41-NEXT: movdqu 16(%rdi), %xmm1
1425 ; X64-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1
1426 ; X64-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
1427 ; X64-SSE41-NEXT: por %xmm1, %xmm0
1428 ; X64-SSE41-NEXT: ptest %xmm0, %xmm0
1429 ; X64-SSE41-NEXT: setne %al
1430 ; X64-SSE41-NEXT: retq
1432 ; X64-AVX1-LABEL: length32_eq_const:
1433 ; X64-AVX1: # %bb.0:
1434 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
1435 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1436 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
1437 ; X64-AVX1-NEXT: setne %al
1438 ; X64-AVX1-NEXT: vzeroupper
1439 ; X64-AVX1-NEXT: retq
1441 ; X64-AVX2-LABEL: length32_eq_const:
1442 ; X64-AVX2: # %bb.0:
1443 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1444 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1445 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
1446 ; X64-AVX2-NEXT: setne %al
1447 ; X64-AVX2-NEXT: vzeroupper
1448 ; X64-AVX2-NEXT: retq
1450 ; X64-AVX512-LABEL: length32_eq_const:
1451 ; X64-AVX512: # %bb.0:
1452 ; X64-AVX512-NEXT: vmovdqu (%rdi), %ymm0
1453 ; X64-AVX512-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1454 ; X64-AVX512-NEXT: vptest %ymm0, %ymm0
1455 ; X64-AVX512-NEXT: setne %al
1456 ; X64-AVX512-NEXT: vzeroupper
1457 ; X64-AVX512-NEXT: retq
1459 ; X64-MIC-AVX-LABEL: length32_eq_const:
1460 ; X64-MIC-AVX: # %bb.0:
1461 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %ymm0
1462 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} ymm1 = [858927408,926299444,825243960,892613426,959985462,858927408,926299444,825243960]
1463 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k0
1464 ; X64-MIC-AVX-NEXT: kortestw %k0, %k0
1465 ; X64-MIC-AVX-NEXT: setne %al
1466 ; X64-MIC-AVX-NEXT: vzeroupper
1467 ; X64-MIC-AVX-NEXT: retq
1468 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 32) nounwind
1469 %c = icmp ne i32 %m, 0
1473 define i32 @length48(ptr %X, ptr %Y) nounwind {
1474 ; X64-LABEL: length48:
1476 ; X64-NEXT: movl $48, %edx
1477 ; X64-NEXT: jmp memcmp # TAILCALL
1478 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 48) nounwind
1482 define i1 @length48_eq(ptr %x, ptr %y) nounwind {
1483 ; X64-SSE-LABEL: length48_eq:
1485 ; X64-SSE-NEXT: pushq %rax
1486 ; X64-SSE-NEXT: movl $48, %edx
1487 ; X64-SSE-NEXT: callq memcmp
1488 ; X64-SSE-NEXT: testl %eax, %eax
1489 ; X64-SSE-NEXT: sete %al
1490 ; X64-SSE-NEXT: popq %rcx
1491 ; X64-SSE-NEXT: retq
1493 ; X64-AVX1-LABEL: length48_eq:
1494 ; X64-AVX1: # %bb.0:
1495 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
1496 ; X64-AVX1-NEXT: vmovups 32(%rdi), %xmm1
1497 ; X64-AVX1-NEXT: vmovups 32(%rsi), %xmm2
1498 ; X64-AVX1-NEXT: vxorps (%rsi), %ymm0, %ymm0
1499 ; X64-AVX1-NEXT: vxorps %ymm2, %ymm1, %ymm1
1500 ; X64-AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
1501 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
1502 ; X64-AVX1-NEXT: sete %al
1503 ; X64-AVX1-NEXT: vzeroupper
1504 ; X64-AVX1-NEXT: retq
1506 ; X64-AVX2-LABEL: length48_eq:
1507 ; X64-AVX2: # %bb.0:
1508 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1509 ; X64-AVX2-NEXT: vmovdqu 32(%rdi), %xmm1
1510 ; X64-AVX2-NEXT: vmovdqu 32(%rsi), %xmm2
1511 ; X64-AVX2-NEXT: vpxor (%rsi), %ymm0, %ymm0
1512 ; X64-AVX2-NEXT: vpxor %ymm2, %ymm1, %ymm1
1513 ; X64-AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
1514 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
1515 ; X64-AVX2-NEXT: sete %al
1516 ; X64-AVX2-NEXT: vzeroupper
1517 ; X64-AVX2-NEXT: retq
1519 ; X64-AVX512-LABEL: length48_eq:
1520 ; X64-AVX512: # %bb.0:
1521 ; X64-AVX512-NEXT: vmovdqu (%rdi), %ymm0
1522 ; X64-AVX512-NEXT: vmovdqu 32(%rdi), %xmm1
1523 ; X64-AVX512-NEXT: vmovdqu 32(%rsi), %xmm2
1524 ; X64-AVX512-NEXT: vpxor (%rsi), %ymm0, %ymm0
1525 ; X64-AVX512-NEXT: vpxor %ymm2, %ymm1, %ymm1
1526 ; X64-AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
1527 ; X64-AVX512-NEXT: vptest %ymm0, %ymm0
1528 ; X64-AVX512-NEXT: sete %al
1529 ; X64-AVX512-NEXT: vzeroupper
1530 ; X64-AVX512-NEXT: retq
1532 ; X64-MIC-AVX-LABEL: length48_eq:
1533 ; X64-MIC-AVX: # %bb.0:
1534 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %ymm0
1535 ; X64-MIC-AVX-NEXT: vmovdqu (%rsi), %ymm1
1536 ; X64-MIC-AVX-NEXT: vmovdqu 32(%rdi), %xmm2
1537 ; X64-MIC-AVX-NEXT: vmovdqu 32(%rsi), %xmm3
1538 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm3, %zmm2, %k0
1539 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k1
1540 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1541 ; X64-MIC-AVX-NEXT: sete %al
1542 ; X64-MIC-AVX-NEXT: vzeroupper
1543 ; X64-MIC-AVX-NEXT: retq
1544 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 48) nounwind
1545 %cmp = icmp eq i32 %call, 0
1549 define i1 @length48_lt(ptr %x, ptr %y) nounwind {
1550 ; X64-LABEL: length48_lt:
1552 ; X64-NEXT: pushq %rax
1553 ; X64-NEXT: movl $48, %edx
1554 ; X64-NEXT: callq memcmp
1555 ; X64-NEXT: shrl $31, %eax
1556 ; X64-NEXT: # kill: def $al killed $al killed $eax
1557 ; X64-NEXT: popq %rcx
1559 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 48) nounwind
1560 %cmp = icmp slt i32 %call, 0
1564 define i1 @length48_gt(ptr %x, ptr %y) nounwind {
1565 ; X64-LABEL: length48_gt:
1567 ; X64-NEXT: pushq %rax
1568 ; X64-NEXT: movl $48, %edx
1569 ; X64-NEXT: callq memcmp
1570 ; X64-NEXT: testl %eax, %eax
1571 ; X64-NEXT: setg %al
1572 ; X64-NEXT: popq %rcx
1574 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 48) nounwind
1575 %cmp = icmp sgt i32 %call, 0
1579 define i1 @length48_eq_prefer128(ptr %x, ptr %y) nounwind "prefer-vector-width"="128" {
1580 ; X64-LABEL: length48_eq_prefer128:
1582 ; X64-NEXT: pushq %rax
1583 ; X64-NEXT: movl $48, %edx
1584 ; X64-NEXT: callq memcmp
1585 ; X64-NEXT: testl %eax, %eax
1586 ; X64-NEXT: sete %al
1587 ; X64-NEXT: popq %rcx
1589 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 48) nounwind
1590 %cmp = icmp eq i32 %call, 0
1594 define i1 @length48_eq_const(ptr %X) nounwind {
1595 ; X64-SSE-LABEL: length48_eq_const:
1597 ; X64-SSE-NEXT: pushq %rax
1598 ; X64-SSE-NEXT: movl $.L.str, %esi
1599 ; X64-SSE-NEXT: movl $48, %edx
1600 ; X64-SSE-NEXT: callq memcmp
1601 ; X64-SSE-NEXT: testl %eax, %eax
1602 ; X64-SSE-NEXT: setne %al
1603 ; X64-SSE-NEXT: popq %rcx
1604 ; X64-SSE-NEXT: retq
1606 ; X64-AVX1-LABEL: length48_eq_const:
1607 ; X64-AVX1: # %bb.0:
1608 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
1609 ; X64-AVX1-NEXT: vmovups 32(%rdi), %xmm1
1610 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1611 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
1612 ; X64-AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
1613 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
1614 ; X64-AVX1-NEXT: setne %al
1615 ; X64-AVX1-NEXT: vzeroupper
1616 ; X64-AVX1-NEXT: retq
1618 ; X64-AVX2-LABEL: length48_eq_const:
1619 ; X64-AVX2: # %bb.0:
1620 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1621 ; X64-AVX2-NEXT: vmovdqu 32(%rdi), %xmm1
1622 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1623 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
1624 ; X64-AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
1625 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
1626 ; X64-AVX2-NEXT: setne %al
1627 ; X64-AVX2-NEXT: vzeroupper
1628 ; X64-AVX2-NEXT: retq
1630 ; X64-AVX512-LABEL: length48_eq_const:
1631 ; X64-AVX512: # %bb.0:
1632 ; X64-AVX512-NEXT: vmovdqu (%rdi), %ymm0
1633 ; X64-AVX512-NEXT: vmovdqu 32(%rdi), %xmm1
1634 ; X64-AVX512-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1635 ; X64-AVX512-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
1636 ; X64-AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
1637 ; X64-AVX512-NEXT: vptest %ymm0, %ymm0
1638 ; X64-AVX512-NEXT: setne %al
1639 ; X64-AVX512-NEXT: vzeroupper
1640 ; X64-AVX512-NEXT: retq
1642 ; X64-MIC-AVX-LABEL: length48_eq_const:
1643 ; X64-MIC-AVX: # %bb.0:
1644 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %ymm0
1645 ; X64-MIC-AVX-NEXT: vmovdqu 32(%rdi), %xmm1
1646 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} ymm2 = [892613426,959985462,858927408,926299444,0,0,0,0]
1647 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm2, %zmm1, %k0
1648 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} ymm1 = [858927408,926299444,825243960,892613426,959985462,858927408,926299444,825243960]
1649 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k1
1650 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1651 ; X64-MIC-AVX-NEXT: setne %al
1652 ; X64-MIC-AVX-NEXT: vzeroupper
1653 ; X64-MIC-AVX-NEXT: retq
1654 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 48) nounwind
1655 %c = icmp ne i32 %m, 0
1659 define i32 @length63(ptr %X, ptr %Y) nounwind {
1660 ; X64-LABEL: length63:
1662 ; X64-NEXT: movl $63, %edx
1663 ; X64-NEXT: jmp memcmp # TAILCALL
1664 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 63) nounwind
1668 define i1 @length63_eq(ptr %x, ptr %y) nounwind {
1669 ; X64-SSE-LABEL: length63_eq:
1671 ; X64-SSE-NEXT: pushq %rax
1672 ; X64-SSE-NEXT: movl $63, %edx
1673 ; X64-SSE-NEXT: callq memcmp
1674 ; X64-SSE-NEXT: testl %eax, %eax
1675 ; X64-SSE-NEXT: setne %al
1676 ; X64-SSE-NEXT: popq %rcx
1677 ; X64-SSE-NEXT: retq
1679 ; X64-AVX1-LABEL: length63_eq:
1680 ; X64-AVX1: # %bb.0:
1681 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
1682 ; X64-AVX1-NEXT: vmovups 31(%rdi), %ymm1
1683 ; X64-AVX1-NEXT: vxorps 31(%rsi), %ymm1, %ymm1
1684 ; X64-AVX1-NEXT: vxorps (%rsi), %ymm0, %ymm0
1685 ; X64-AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
1686 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
1687 ; X64-AVX1-NEXT: setne %al
1688 ; X64-AVX1-NEXT: vzeroupper
1689 ; X64-AVX1-NEXT: retq
1691 ; X64-AVX2-LABEL: length63_eq:
1692 ; X64-AVX2: # %bb.0:
1693 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1694 ; X64-AVX2-NEXT: vmovdqu 31(%rdi), %ymm1
1695 ; X64-AVX2-NEXT: vpxor 31(%rsi), %ymm1, %ymm1
1696 ; X64-AVX2-NEXT: vpxor (%rsi), %ymm0, %ymm0
1697 ; X64-AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
1698 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
1699 ; X64-AVX2-NEXT: setne %al
1700 ; X64-AVX2-NEXT: vzeroupper
1701 ; X64-AVX2-NEXT: retq
1703 ; X64-AVX512-LABEL: length63_eq:
1704 ; X64-AVX512: # %bb.0:
1705 ; X64-AVX512-NEXT: vmovdqu (%rdi), %ymm0
1706 ; X64-AVX512-NEXT: vmovdqu 31(%rdi), %ymm1
1707 ; X64-AVX512-NEXT: vpxor 31(%rsi), %ymm1, %ymm1
1708 ; X64-AVX512-NEXT: vpxor (%rsi), %ymm0, %ymm0
1709 ; X64-AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
1710 ; X64-AVX512-NEXT: vptest %ymm0, %ymm0
1711 ; X64-AVX512-NEXT: setne %al
1712 ; X64-AVX512-NEXT: vzeroupper
1713 ; X64-AVX512-NEXT: retq
1715 ; X64-MIC-AVX-LABEL: length63_eq:
1716 ; X64-MIC-AVX: # %bb.0:
1717 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %ymm0
1718 ; X64-MIC-AVX-NEXT: vmovdqu 31(%rdi), %ymm1
1719 ; X64-MIC-AVX-NEXT: vmovdqu (%rsi), %ymm2
1720 ; X64-MIC-AVX-NEXT: vmovdqu 31(%rsi), %ymm3
1721 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm3, %zmm1, %k0
1722 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm2, %zmm0, %k1
1723 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1724 ; X64-MIC-AVX-NEXT: setne %al
1725 ; X64-MIC-AVX-NEXT: vzeroupper
1726 ; X64-MIC-AVX-NEXT: retq
1727 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 63) nounwind
1728 %cmp = icmp ne i32 %call, 0
1732 define i1 @length63_lt(ptr %x, ptr %y) nounwind {
1733 ; X64-LABEL: length63_lt:
1735 ; X64-NEXT: pushq %rax
1736 ; X64-NEXT: movl $63, %edx
1737 ; X64-NEXT: callq memcmp
1738 ; X64-NEXT: shrl $31, %eax
1739 ; X64-NEXT: # kill: def $al killed $al killed $eax
1740 ; X64-NEXT: popq %rcx
1742 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 63) nounwind
1743 %cmp = icmp slt i32 %call, 0
1747 define i1 @length63_gt(ptr %x, ptr %y) nounwind {
1748 ; X64-LABEL: length63_gt:
1750 ; X64-NEXT: pushq %rax
1751 ; X64-NEXT: movl $63, %edx
1752 ; X64-NEXT: callq memcmp
1753 ; X64-NEXT: testl %eax, %eax
1754 ; X64-NEXT: setg %al
1755 ; X64-NEXT: popq %rcx
1757 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 63) nounwind
1758 %cmp = icmp sgt i32 %call, 0
1762 define i1 @length63_eq_const(ptr %X) nounwind {
1763 ; X64-SSE-LABEL: length63_eq_const:
1765 ; X64-SSE-NEXT: pushq %rax
1766 ; X64-SSE-NEXT: movl $.L.str, %esi
1767 ; X64-SSE-NEXT: movl $63, %edx
1768 ; X64-SSE-NEXT: callq memcmp
1769 ; X64-SSE-NEXT: testl %eax, %eax
1770 ; X64-SSE-NEXT: sete %al
1771 ; X64-SSE-NEXT: popq %rcx
1772 ; X64-SSE-NEXT: retq
1774 ; X64-AVX1-LABEL: length63_eq_const:
1775 ; X64-AVX1: # %bb.0:
1776 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
1777 ; X64-AVX1-NEXT: vmovups 31(%rdi), %ymm1
1778 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
1779 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1780 ; X64-AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
1781 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
1782 ; X64-AVX1-NEXT: sete %al
1783 ; X64-AVX1-NEXT: vzeroupper
1784 ; X64-AVX1-NEXT: retq
1786 ; X64-AVX2-LABEL: length63_eq_const:
1787 ; X64-AVX2: # %bb.0:
1788 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1789 ; X64-AVX2-NEXT: vmovdqu 31(%rdi), %ymm1
1790 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
1791 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1792 ; X64-AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
1793 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
1794 ; X64-AVX2-NEXT: sete %al
1795 ; X64-AVX2-NEXT: vzeroupper
1796 ; X64-AVX2-NEXT: retq
1798 ; X64-AVX512-LABEL: length63_eq_const:
1799 ; X64-AVX512: # %bb.0:
1800 ; X64-AVX512-NEXT: vmovdqu (%rdi), %ymm0
1801 ; X64-AVX512-NEXT: vmovdqu 31(%rdi), %ymm1
1802 ; X64-AVX512-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
1803 ; X64-AVX512-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1804 ; X64-AVX512-NEXT: vpor %ymm1, %ymm0, %ymm0
1805 ; X64-AVX512-NEXT: vptest %ymm0, %ymm0
1806 ; X64-AVX512-NEXT: sete %al
1807 ; X64-AVX512-NEXT: vzeroupper
1808 ; X64-AVX512-NEXT: retq
1810 ; X64-MIC-AVX-LABEL: length63_eq_const:
1811 ; X64-MIC-AVX: # %bb.0:
1812 ; X64-MIC-AVX-NEXT: vmovdqu (%rdi), %ymm0
1813 ; X64-MIC-AVX-NEXT: vmovdqu 31(%rdi), %ymm1
1814 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} ymm2 = [875770417,943142453,842084409,909456435,809056311,875770417,943142453,842084409]
1815 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm2, %zmm1, %k0
1816 ; X64-MIC-AVX-NEXT: vmovdqa {{.*#+}} ymm1 = [858927408,926299444,825243960,892613426,959985462,858927408,926299444,825243960]
1817 ; X64-MIC-AVX-NEXT: vpcmpneqd %zmm1, %zmm0, %k1
1818 ; X64-MIC-AVX-NEXT: kortestw %k0, %k1
1819 ; X64-MIC-AVX-NEXT: sete %al
1820 ; X64-MIC-AVX-NEXT: vzeroupper
1821 ; X64-MIC-AVX-NEXT: retq
1822 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 63) nounwind
1823 %c = icmp eq i32 %m, 0
1827 define i32 @length64(ptr %X, ptr %Y) nounwind {
1828 ; X64-LABEL: length64:
1830 ; X64-NEXT: movl $64, %edx
1831 ; X64-NEXT: jmp memcmp # TAILCALL
1832 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 64) nounwind
1836 define i1 @length64_eq(ptr %x, ptr %y) nounwind {
1837 ; X64-SSE-LABEL: length64_eq:
1839 ; X64-SSE-NEXT: pushq %rax
1840 ; X64-SSE-NEXT: movl $64, %edx
1841 ; X64-SSE-NEXT: callq memcmp
1842 ; X64-SSE-NEXT: testl %eax, %eax
1843 ; X64-SSE-NEXT: setne %al
1844 ; X64-SSE-NEXT: popq %rcx
1845 ; X64-SSE-NEXT: retq
1847 ; X64-AVX1-LABEL: length64_eq:
1848 ; X64-AVX1: # %bb.0:
1849 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
1850 ; X64-AVX1-NEXT: vmovups 32(%rdi), %ymm1
1851 ; X64-AVX1-NEXT: vxorps 32(%rsi), %ymm1, %ymm1
1852 ; X64-AVX1-NEXT: vxorps (%rsi), %ymm0, %ymm0
1853 ; X64-AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
1854 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
1855 ; X64-AVX1-NEXT: setne %al
1856 ; X64-AVX1-NEXT: vzeroupper
1857 ; X64-AVX1-NEXT: retq
1859 ; X64-AVX2-LABEL: length64_eq:
1860 ; X64-AVX2: # %bb.0:
1861 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1862 ; X64-AVX2-NEXT: vmovdqu 32(%rdi), %ymm1
1863 ; X64-AVX2-NEXT: vpxor 32(%rsi), %ymm1, %ymm1
1864 ; X64-AVX2-NEXT: vpxor (%rsi), %ymm0, %ymm0
1865 ; X64-AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
1866 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
1867 ; X64-AVX2-NEXT: setne %al
1868 ; X64-AVX2-NEXT: vzeroupper
1869 ; X64-AVX2-NEXT: retq
1871 ; X64-AVX512-LABEL: length64_eq:
1872 ; X64-AVX512: # %bb.0:
1873 ; X64-AVX512-NEXT: vmovdqu64 (%rdi), %zmm0
1874 ; X64-AVX512-NEXT: vpcmpneqd (%rsi), %zmm0, %k0
1875 ; X64-AVX512-NEXT: kortestw %k0, %k0
1876 ; X64-AVX512-NEXT: setne %al
1877 ; X64-AVX512-NEXT: vzeroupper
1878 ; X64-AVX512-NEXT: retq
1880 ; X64-MIC-AVX2-LABEL: length64_eq:
1881 ; X64-MIC-AVX2: # %bb.0:
1882 ; X64-MIC-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1883 ; X64-MIC-AVX2-NEXT: vmovdqu 32(%rdi), %ymm1
1884 ; X64-MIC-AVX2-NEXT: vmovdqu (%rsi), %ymm2
1885 ; X64-MIC-AVX2-NEXT: vmovdqu 32(%rsi), %ymm3
1886 ; X64-MIC-AVX2-NEXT: vpcmpneqd %zmm3, %zmm1, %k0
1887 ; X64-MIC-AVX2-NEXT: vpcmpneqd %zmm2, %zmm0, %k1
1888 ; X64-MIC-AVX2-NEXT: kortestw %k0, %k1
1889 ; X64-MIC-AVX2-NEXT: setne %al
1890 ; X64-MIC-AVX2-NEXT: vzeroupper
1891 ; X64-MIC-AVX2-NEXT: retq
1893 ; X64-MIC-AVX512F-LABEL: length64_eq:
1894 ; X64-MIC-AVX512F: # %bb.0:
1895 ; X64-MIC-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
1896 ; X64-MIC-AVX512F-NEXT: vpcmpneqd (%rsi), %zmm0, %k0
1897 ; X64-MIC-AVX512F-NEXT: kortestw %k0, %k0
1898 ; X64-MIC-AVX512F-NEXT: setne %al
1899 ; X64-MIC-AVX512F-NEXT: vzeroupper
1900 ; X64-MIC-AVX512F-NEXT: retq
1901 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 64) nounwind
1902 %cmp = icmp ne i32 %call, 0
1906 define i1 @length64_lt(ptr %x, ptr %y) nounwind {
1907 ; X64-LABEL: length64_lt:
1909 ; X64-NEXT: pushq %rax
1910 ; X64-NEXT: movl $64, %edx
1911 ; X64-NEXT: callq memcmp
1912 ; X64-NEXT: shrl $31, %eax
1913 ; X64-NEXT: # kill: def $al killed $al killed $eax
1914 ; X64-NEXT: popq %rcx
1916 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 64) nounwind
1917 %cmp = icmp slt i32 %call, 0
1921 define i1 @length64_gt(ptr %x, ptr %y) nounwind {
1922 ; X64-LABEL: length64_gt:
1924 ; X64-NEXT: pushq %rax
1925 ; X64-NEXT: movl $64, %edx
1926 ; X64-NEXT: callq memcmp
1927 ; X64-NEXT: testl %eax, %eax
1928 ; X64-NEXT: setg %al
1929 ; X64-NEXT: popq %rcx
1931 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 64) nounwind
1932 %cmp = icmp sgt i32 %call, 0
1936 define i1 @length64_eq_const(ptr %X) nounwind {
1937 ; X64-SSE-LABEL: length64_eq_const:
1939 ; X64-SSE-NEXT: pushq %rax
1940 ; X64-SSE-NEXT: movl $.L.str, %esi
1941 ; X64-SSE-NEXT: movl $64, %edx
1942 ; X64-SSE-NEXT: callq memcmp
1943 ; X64-SSE-NEXT: testl %eax, %eax
1944 ; X64-SSE-NEXT: sete %al
1945 ; X64-SSE-NEXT: popq %rcx
1946 ; X64-SSE-NEXT: retq
1948 ; X64-AVX1-LABEL: length64_eq_const:
1949 ; X64-AVX1: # %bb.0:
1950 ; X64-AVX1-NEXT: vmovups (%rdi), %ymm0
1951 ; X64-AVX1-NEXT: vmovups 32(%rdi), %ymm1
1952 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
1953 ; X64-AVX1-NEXT: vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1954 ; X64-AVX1-NEXT: vorps %ymm1, %ymm0, %ymm0
1955 ; X64-AVX1-NEXT: vptest %ymm0, %ymm0
1956 ; X64-AVX1-NEXT: sete %al
1957 ; X64-AVX1-NEXT: vzeroupper
1958 ; X64-AVX1-NEXT: retq
1960 ; X64-AVX2-LABEL: length64_eq_const:
1961 ; X64-AVX2: # %bb.0:
1962 ; X64-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1963 ; X64-AVX2-NEXT: vmovdqu 32(%rdi), %ymm1
1964 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm1, %ymm1
1965 ; X64-AVX2-NEXT: vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0
1966 ; X64-AVX2-NEXT: vpor %ymm1, %ymm0, %ymm0
1967 ; X64-AVX2-NEXT: vptest %ymm0, %ymm0
1968 ; X64-AVX2-NEXT: sete %al
1969 ; X64-AVX2-NEXT: vzeroupper
1970 ; X64-AVX2-NEXT: retq
1972 ; X64-AVX512-LABEL: length64_eq_const:
1973 ; X64-AVX512: # %bb.0:
1974 ; X64-AVX512-NEXT: vmovdqu64 (%rdi), %zmm0
1975 ; X64-AVX512-NEXT: vpcmpneqd .L.str(%rip), %zmm0, %k0
1976 ; X64-AVX512-NEXT: kortestw %k0, %k0
1977 ; X64-AVX512-NEXT: sete %al
1978 ; X64-AVX512-NEXT: vzeroupper
1979 ; X64-AVX512-NEXT: retq
1981 ; X64-MIC-AVX2-LABEL: length64_eq_const:
1982 ; X64-MIC-AVX2: # %bb.0:
1983 ; X64-MIC-AVX2-NEXT: vmovdqu (%rdi), %ymm0
1984 ; X64-MIC-AVX2-NEXT: vmovdqu 32(%rdi), %ymm1
1985 ; X64-MIC-AVX2-NEXT: vmovdqa {{.*#+}} ymm2 = [892613426,959985462,858927408,926299444,825243960,892613426,959985462,858927408]
1986 ; X64-MIC-AVX2-NEXT: vpcmpneqd %zmm2, %zmm1, %k0
1987 ; X64-MIC-AVX2-NEXT: vmovdqa {{.*#+}} ymm1 = [858927408,926299444,825243960,892613426,959985462,858927408,926299444,825243960]
1988 ; X64-MIC-AVX2-NEXT: vpcmpneqd %zmm1, %zmm0, %k1
1989 ; X64-MIC-AVX2-NEXT: kortestw %k0, %k1
1990 ; X64-MIC-AVX2-NEXT: sete %al
1991 ; X64-MIC-AVX2-NEXT: vzeroupper
1992 ; X64-MIC-AVX2-NEXT: retq
1994 ; X64-MIC-AVX512F-LABEL: length64_eq_const:
1995 ; X64-MIC-AVX512F: # %bb.0:
1996 ; X64-MIC-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
1997 ; X64-MIC-AVX512F-NEXT: vpcmpneqd .L.str(%rip), %zmm0, %k0
1998 ; X64-MIC-AVX512F-NEXT: kortestw %k0, %k0
1999 ; X64-MIC-AVX512F-NEXT: sete %al
2000 ; X64-MIC-AVX512F-NEXT: vzeroupper
2001 ; X64-MIC-AVX512F-NEXT: retq
2002 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 64) nounwind
2003 %c = icmp eq i32 %m, 0
2007 define i32 @length96(ptr %X, ptr %Y) nounwind {
2008 ; X64-LABEL: length96:
2010 ; X64-NEXT: movl $96, %edx
2011 ; X64-NEXT: jmp memcmp # TAILCALL
2012 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 96) nounwind
2016 define i1 @length96_eq(ptr %x, ptr %y) nounwind {
2017 ; X64-SSE-LABEL: length96_eq:
2019 ; X64-SSE-NEXT: pushq %rax
2020 ; X64-SSE-NEXT: movl $96, %edx
2021 ; X64-SSE-NEXT: callq memcmp
2022 ; X64-SSE-NEXT: testl %eax, %eax
2023 ; X64-SSE-NEXT: setne %al
2024 ; X64-SSE-NEXT: popq %rcx
2025 ; X64-SSE-NEXT: retq
2027 ; X64-AVX1-LABEL: length96_eq:
2028 ; X64-AVX1: # %bb.0:
2029 ; X64-AVX1-NEXT: pushq %rax
2030 ; X64-AVX1-NEXT: movl $96, %edx
2031 ; X64-AVX1-NEXT: callq memcmp
2032 ; X64-AVX1-NEXT: testl %eax, %eax
2033 ; X64-AVX1-NEXT: setne %al
2034 ; X64-AVX1-NEXT: popq %rcx
2035 ; X64-AVX1-NEXT: retq
2037 ; X64-AVX2-LABEL: length96_eq:
2038 ; X64-AVX2: # %bb.0:
2039 ; X64-AVX2-NEXT: pushq %rax
2040 ; X64-AVX2-NEXT: movl $96, %edx
2041 ; X64-AVX2-NEXT: callq memcmp
2042 ; X64-AVX2-NEXT: testl %eax, %eax
2043 ; X64-AVX2-NEXT: setne %al
2044 ; X64-AVX2-NEXT: popq %rcx
2045 ; X64-AVX2-NEXT: retq
2047 ; X64-AVX512BW-LABEL: length96_eq:
2048 ; X64-AVX512BW: # %bb.0:
2049 ; X64-AVX512BW-NEXT: vmovdqu64 (%rdi), %zmm0
2050 ; X64-AVX512BW-NEXT: vmovdqu 64(%rdi), %ymm1
2051 ; X64-AVX512BW-NEXT: vmovdqu 64(%rsi), %ymm2
2052 ; X64-AVX512BW-NEXT: vpcmpneqb (%rsi), %zmm0, %k0
2053 ; X64-AVX512BW-NEXT: vpcmpneqb %zmm2, %zmm1, %k1
2054 ; X64-AVX512BW-NEXT: kortestq %k1, %k0
2055 ; X64-AVX512BW-NEXT: setne %al
2056 ; X64-AVX512BW-NEXT: vzeroupper
2057 ; X64-AVX512BW-NEXT: retq
2059 ; X64-AVX512F-LABEL: length96_eq:
2060 ; X64-AVX512F: # %bb.0:
2061 ; X64-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2062 ; X64-AVX512F-NEXT: vmovdqu 64(%rdi), %ymm1
2063 ; X64-AVX512F-NEXT: vmovdqu 64(%rsi), %ymm2
2064 ; X64-AVX512F-NEXT: vpcmpneqd (%rsi), %zmm0, %k0
2065 ; X64-AVX512F-NEXT: vpcmpneqd %zmm2, %zmm1, %k1
2066 ; X64-AVX512F-NEXT: kortestw %k1, %k0
2067 ; X64-AVX512F-NEXT: setne %al
2068 ; X64-AVX512F-NEXT: vzeroupper
2069 ; X64-AVX512F-NEXT: retq
2071 ; X64-MIC-AVX2-LABEL: length96_eq:
2072 ; X64-MIC-AVX2: # %bb.0:
2073 ; X64-MIC-AVX2-NEXT: pushq %rax
2074 ; X64-MIC-AVX2-NEXT: movl $96, %edx
2075 ; X64-MIC-AVX2-NEXT: callq memcmp
2076 ; X64-MIC-AVX2-NEXT: testl %eax, %eax
2077 ; X64-MIC-AVX2-NEXT: setne %al
2078 ; X64-MIC-AVX2-NEXT: popq %rcx
2079 ; X64-MIC-AVX2-NEXT: retq
2081 ; X64-MIC-AVX512F-LABEL: length96_eq:
2082 ; X64-MIC-AVX512F: # %bb.0:
2083 ; X64-MIC-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2084 ; X64-MIC-AVX512F-NEXT: vmovdqu 64(%rdi), %ymm1
2085 ; X64-MIC-AVX512F-NEXT: vmovdqu 64(%rsi), %ymm2
2086 ; X64-MIC-AVX512F-NEXT: vpcmpneqd (%rsi), %zmm0, %k0
2087 ; X64-MIC-AVX512F-NEXT: vpcmpneqd %zmm2, %zmm1, %k1
2088 ; X64-MIC-AVX512F-NEXT: kortestw %k1, %k0
2089 ; X64-MIC-AVX512F-NEXT: setne %al
2090 ; X64-MIC-AVX512F-NEXT: vzeroupper
2091 ; X64-MIC-AVX512F-NEXT: retq
2092 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 96) nounwind
2093 %cmp = icmp ne i32 %call, 0
2097 define i1 @length96_lt(ptr %x, ptr %y) nounwind {
2098 ; X64-LABEL: length96_lt:
2100 ; X64-NEXT: pushq %rax
2101 ; X64-NEXT: movl $96, %edx
2102 ; X64-NEXT: callq memcmp
2103 ; X64-NEXT: shrl $31, %eax
2104 ; X64-NEXT: # kill: def $al killed $al killed $eax
2105 ; X64-NEXT: popq %rcx
2107 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 96) nounwind
2108 %cmp = icmp slt i32 %call, 0
2112 define i1 @length96_gt(ptr %x, ptr %y) nounwind {
2113 ; X64-LABEL: length96_gt:
2115 ; X64-NEXT: pushq %rax
2116 ; X64-NEXT: movl $96, %edx
2117 ; X64-NEXT: callq memcmp
2118 ; X64-NEXT: testl %eax, %eax
2119 ; X64-NEXT: setg %al
2120 ; X64-NEXT: popq %rcx
2122 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 96) nounwind
2123 %cmp = icmp sgt i32 %call, 0
2127 define i1 @length96_eq_const(ptr %X) nounwind {
2128 ; X64-SSE-LABEL: length96_eq_const:
2130 ; X64-SSE-NEXT: pushq %rax
2131 ; X64-SSE-NEXT: movl $.L.str, %esi
2132 ; X64-SSE-NEXT: movl $96, %edx
2133 ; X64-SSE-NEXT: callq memcmp
2134 ; X64-SSE-NEXT: testl %eax, %eax
2135 ; X64-SSE-NEXT: sete %al
2136 ; X64-SSE-NEXT: popq %rcx
2137 ; X64-SSE-NEXT: retq
2139 ; X64-AVX1-LABEL: length96_eq_const:
2140 ; X64-AVX1: # %bb.0:
2141 ; X64-AVX1-NEXT: pushq %rax
2142 ; X64-AVX1-NEXT: movl $.L.str, %esi
2143 ; X64-AVX1-NEXT: movl $96, %edx
2144 ; X64-AVX1-NEXT: callq memcmp
2145 ; X64-AVX1-NEXT: testl %eax, %eax
2146 ; X64-AVX1-NEXT: sete %al
2147 ; X64-AVX1-NEXT: popq %rcx
2148 ; X64-AVX1-NEXT: retq
2150 ; X64-AVX2-LABEL: length96_eq_const:
2151 ; X64-AVX2: # %bb.0:
2152 ; X64-AVX2-NEXT: pushq %rax
2153 ; X64-AVX2-NEXT: movl $.L.str, %esi
2154 ; X64-AVX2-NEXT: movl $96, %edx
2155 ; X64-AVX2-NEXT: callq memcmp
2156 ; X64-AVX2-NEXT: testl %eax, %eax
2157 ; X64-AVX2-NEXT: sete %al
2158 ; X64-AVX2-NEXT: popq %rcx
2159 ; X64-AVX2-NEXT: retq
2161 ; X64-AVX512BW-LABEL: length96_eq_const:
2162 ; X64-AVX512BW: # %bb.0:
2163 ; X64-AVX512BW-NEXT: vmovdqu64 (%rdi), %zmm0
2164 ; X64-AVX512BW-NEXT: vmovdqu 64(%rdi), %ymm1
2165 ; X64-AVX512BW-NEXT: vpcmpneqb .L.str(%rip), %zmm0, %k0
2166 ; X64-AVX512BW-NEXT: vpcmpneqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %zmm1, %k1
2167 ; X64-AVX512BW-NEXT: kortestq %k1, %k0
2168 ; X64-AVX512BW-NEXT: sete %al
2169 ; X64-AVX512BW-NEXT: vzeroupper
2170 ; X64-AVX512BW-NEXT: retq
2172 ; X64-AVX512F-LABEL: length96_eq_const:
2173 ; X64-AVX512F: # %bb.0:
2174 ; X64-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2175 ; X64-AVX512F-NEXT: vmovdqu 64(%rdi), %ymm1
2176 ; X64-AVX512F-NEXT: vpcmpneqd .L.str(%rip), %zmm0, %k0
2177 ; X64-AVX512F-NEXT: vpcmpneqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %zmm1, %k1
2178 ; X64-AVX512F-NEXT: kortestw %k1, %k0
2179 ; X64-AVX512F-NEXT: sete %al
2180 ; X64-AVX512F-NEXT: vzeroupper
2181 ; X64-AVX512F-NEXT: retq
2183 ; X64-MIC-AVX2-LABEL: length96_eq_const:
2184 ; X64-MIC-AVX2: # %bb.0:
2185 ; X64-MIC-AVX2-NEXT: pushq %rax
2186 ; X64-MIC-AVX2-NEXT: movl $.L.str, %esi
2187 ; X64-MIC-AVX2-NEXT: movl $96, %edx
2188 ; X64-MIC-AVX2-NEXT: callq memcmp
2189 ; X64-MIC-AVX2-NEXT: testl %eax, %eax
2190 ; X64-MIC-AVX2-NEXT: sete %al
2191 ; X64-MIC-AVX2-NEXT: popq %rcx
2192 ; X64-MIC-AVX2-NEXT: retq
2194 ; X64-MIC-AVX512F-LABEL: length96_eq_const:
2195 ; X64-MIC-AVX512F: # %bb.0:
2196 ; X64-MIC-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2197 ; X64-MIC-AVX512F-NEXT: vmovdqu 64(%rdi), %ymm1
2198 ; X64-MIC-AVX512F-NEXT: vpcmpneqd .L.str(%rip), %zmm0, %k0
2199 ; X64-MIC-AVX512F-NEXT: vpcmpneqd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %zmm1, %k1
2200 ; X64-MIC-AVX512F-NEXT: kortestw %k1, %k0
2201 ; X64-MIC-AVX512F-NEXT: sete %al
2202 ; X64-MIC-AVX512F-NEXT: vzeroupper
2203 ; X64-MIC-AVX512F-NEXT: retq
2204 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 96) nounwind
2205 %c = icmp eq i32 %m, 0
2209 define i32 @length127(ptr %X, ptr %Y) nounwind {
2210 ; X64-LABEL: length127:
2212 ; X64-NEXT: movl $127, %edx
2213 ; X64-NEXT: jmp memcmp # TAILCALL
2214 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 127) nounwind
2218 define i1 @length127_eq(ptr %x, ptr %y) nounwind {
2219 ; X64-SSE-LABEL: length127_eq:
2221 ; X64-SSE-NEXT: pushq %rax
2222 ; X64-SSE-NEXT: movl $127, %edx
2223 ; X64-SSE-NEXT: callq memcmp
2224 ; X64-SSE-NEXT: testl %eax, %eax
2225 ; X64-SSE-NEXT: setne %al
2226 ; X64-SSE-NEXT: popq %rcx
2227 ; X64-SSE-NEXT: retq
2229 ; X64-AVX1-LABEL: length127_eq:
2230 ; X64-AVX1: # %bb.0:
2231 ; X64-AVX1-NEXT: pushq %rax
2232 ; X64-AVX1-NEXT: movl $127, %edx
2233 ; X64-AVX1-NEXT: callq memcmp
2234 ; X64-AVX1-NEXT: testl %eax, %eax
2235 ; X64-AVX1-NEXT: setne %al
2236 ; X64-AVX1-NEXT: popq %rcx
2237 ; X64-AVX1-NEXT: retq
2239 ; X64-AVX2-LABEL: length127_eq:
2240 ; X64-AVX2: # %bb.0:
2241 ; X64-AVX2-NEXT: pushq %rax
2242 ; X64-AVX2-NEXT: movl $127, %edx
2243 ; X64-AVX2-NEXT: callq memcmp
2244 ; X64-AVX2-NEXT: testl %eax, %eax
2245 ; X64-AVX2-NEXT: setne %al
2246 ; X64-AVX2-NEXT: popq %rcx
2247 ; X64-AVX2-NEXT: retq
2249 ; X64-AVX512BW-LABEL: length127_eq:
2250 ; X64-AVX512BW: # %bb.0:
2251 ; X64-AVX512BW-NEXT: vmovdqu64 (%rdi), %zmm0
2252 ; X64-AVX512BW-NEXT: vmovdqu64 63(%rdi), %zmm1
2253 ; X64-AVX512BW-NEXT: vpcmpneqb 63(%rsi), %zmm1, %k0
2254 ; X64-AVX512BW-NEXT: vpcmpneqb (%rsi), %zmm0, %k1
2255 ; X64-AVX512BW-NEXT: kortestq %k0, %k1
2256 ; X64-AVX512BW-NEXT: setne %al
2257 ; X64-AVX512BW-NEXT: vzeroupper
2258 ; X64-AVX512BW-NEXT: retq
2260 ; X64-AVX512F-LABEL: length127_eq:
2261 ; X64-AVX512F: # %bb.0:
2262 ; X64-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2263 ; X64-AVX512F-NEXT: vmovdqu64 63(%rdi), %zmm1
2264 ; X64-AVX512F-NEXT: vpcmpneqd 63(%rsi), %zmm1, %k0
2265 ; X64-AVX512F-NEXT: vpcmpneqd (%rsi), %zmm0, %k1
2266 ; X64-AVX512F-NEXT: kortestw %k0, %k1
2267 ; X64-AVX512F-NEXT: setne %al
2268 ; X64-AVX512F-NEXT: vzeroupper
2269 ; X64-AVX512F-NEXT: retq
2271 ; X64-MIC-AVX2-LABEL: length127_eq:
2272 ; X64-MIC-AVX2: # %bb.0:
2273 ; X64-MIC-AVX2-NEXT: pushq %rax
2274 ; X64-MIC-AVX2-NEXT: movl $127, %edx
2275 ; X64-MIC-AVX2-NEXT: callq memcmp
2276 ; X64-MIC-AVX2-NEXT: testl %eax, %eax
2277 ; X64-MIC-AVX2-NEXT: setne %al
2278 ; X64-MIC-AVX2-NEXT: popq %rcx
2279 ; X64-MIC-AVX2-NEXT: retq
2281 ; X64-MIC-AVX512F-LABEL: length127_eq:
2282 ; X64-MIC-AVX512F: # %bb.0:
2283 ; X64-MIC-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2284 ; X64-MIC-AVX512F-NEXT: vmovdqu64 63(%rdi), %zmm1
2285 ; X64-MIC-AVX512F-NEXT: vpcmpneqd 63(%rsi), %zmm1, %k0
2286 ; X64-MIC-AVX512F-NEXT: vpcmpneqd (%rsi), %zmm0, %k1
2287 ; X64-MIC-AVX512F-NEXT: kortestw %k0, %k1
2288 ; X64-MIC-AVX512F-NEXT: setne %al
2289 ; X64-MIC-AVX512F-NEXT: vzeroupper
2290 ; X64-MIC-AVX512F-NEXT: retq
2291 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 127) nounwind
2292 %cmp = icmp ne i32 %call, 0
2296 define i1 @length127_lt(ptr %x, ptr %y) nounwind {
2297 ; X64-LABEL: length127_lt:
2299 ; X64-NEXT: pushq %rax
2300 ; X64-NEXT: movl $127, %edx
2301 ; X64-NEXT: callq memcmp
2302 ; X64-NEXT: shrl $31, %eax
2303 ; X64-NEXT: # kill: def $al killed $al killed $eax
2304 ; X64-NEXT: popq %rcx
2306 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 127) nounwind
2307 %cmp = icmp slt i32 %call, 0
2311 define i1 @length127_gt(ptr %x, ptr %y) nounwind {
2312 ; X64-LABEL: length127_gt:
2314 ; X64-NEXT: pushq %rax
2315 ; X64-NEXT: movl $127, %edx
2316 ; X64-NEXT: callq memcmp
2317 ; X64-NEXT: testl %eax, %eax
2318 ; X64-NEXT: setg %al
2319 ; X64-NEXT: popq %rcx
2321 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 127) nounwind
2322 %cmp = icmp sgt i32 %call, 0
2326 define i1 @length127_eq_const(ptr %X) nounwind {
2327 ; X64-SSE-LABEL: length127_eq_const:
2329 ; X64-SSE-NEXT: pushq %rax
2330 ; X64-SSE-NEXT: movl $.L.str, %esi
2331 ; X64-SSE-NEXT: movl $127, %edx
2332 ; X64-SSE-NEXT: callq memcmp
2333 ; X64-SSE-NEXT: testl %eax, %eax
2334 ; X64-SSE-NEXT: sete %al
2335 ; X64-SSE-NEXT: popq %rcx
2336 ; X64-SSE-NEXT: retq
2338 ; X64-AVX1-LABEL: length127_eq_const:
2339 ; X64-AVX1: # %bb.0:
2340 ; X64-AVX1-NEXT: pushq %rax
2341 ; X64-AVX1-NEXT: movl $.L.str, %esi
2342 ; X64-AVX1-NEXT: movl $127, %edx
2343 ; X64-AVX1-NEXT: callq memcmp
2344 ; X64-AVX1-NEXT: testl %eax, %eax
2345 ; X64-AVX1-NEXT: sete %al
2346 ; X64-AVX1-NEXT: popq %rcx
2347 ; X64-AVX1-NEXT: retq
2349 ; X64-AVX2-LABEL: length127_eq_const:
2350 ; X64-AVX2: # %bb.0:
2351 ; X64-AVX2-NEXT: pushq %rax
2352 ; X64-AVX2-NEXT: movl $.L.str, %esi
2353 ; X64-AVX2-NEXT: movl $127, %edx
2354 ; X64-AVX2-NEXT: callq memcmp
2355 ; X64-AVX2-NEXT: testl %eax, %eax
2356 ; X64-AVX2-NEXT: sete %al
2357 ; X64-AVX2-NEXT: popq %rcx
2358 ; X64-AVX2-NEXT: retq
2360 ; X64-AVX512BW-LABEL: length127_eq_const:
2361 ; X64-AVX512BW: # %bb.0:
2362 ; X64-AVX512BW-NEXT: vmovdqu64 (%rdi), %zmm0
2363 ; X64-AVX512BW-NEXT: vmovdqu64 63(%rdi), %zmm1
2364 ; X64-AVX512BW-NEXT: vpcmpneqb .L.str+63(%rip), %zmm1, %k0
2365 ; X64-AVX512BW-NEXT: vpcmpneqb .L.str(%rip), %zmm0, %k1
2366 ; X64-AVX512BW-NEXT: kortestq %k0, %k1
2367 ; X64-AVX512BW-NEXT: sete %al
2368 ; X64-AVX512BW-NEXT: vzeroupper
2369 ; X64-AVX512BW-NEXT: retq
2371 ; X64-AVX512F-LABEL: length127_eq_const:
2372 ; X64-AVX512F: # %bb.0:
2373 ; X64-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2374 ; X64-AVX512F-NEXT: vmovdqu64 63(%rdi), %zmm1
2375 ; X64-AVX512F-NEXT: vpcmpneqd .L.str+63(%rip), %zmm1, %k0
2376 ; X64-AVX512F-NEXT: vpcmpneqd .L.str(%rip), %zmm0, %k1
2377 ; X64-AVX512F-NEXT: kortestw %k0, %k1
2378 ; X64-AVX512F-NEXT: sete %al
2379 ; X64-AVX512F-NEXT: vzeroupper
2380 ; X64-AVX512F-NEXT: retq
2382 ; X64-MIC-AVX2-LABEL: length127_eq_const:
2383 ; X64-MIC-AVX2: # %bb.0:
2384 ; X64-MIC-AVX2-NEXT: pushq %rax
2385 ; X64-MIC-AVX2-NEXT: movl $.L.str, %esi
2386 ; X64-MIC-AVX2-NEXT: movl $127, %edx
2387 ; X64-MIC-AVX2-NEXT: callq memcmp
2388 ; X64-MIC-AVX2-NEXT: testl %eax, %eax
2389 ; X64-MIC-AVX2-NEXT: sete %al
2390 ; X64-MIC-AVX2-NEXT: popq %rcx
2391 ; X64-MIC-AVX2-NEXT: retq
2393 ; X64-MIC-AVX512F-LABEL: length127_eq_const:
2394 ; X64-MIC-AVX512F: # %bb.0:
2395 ; X64-MIC-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2396 ; X64-MIC-AVX512F-NEXT: vmovdqu64 63(%rdi), %zmm1
2397 ; X64-MIC-AVX512F-NEXT: vpcmpneqd .L.str+63(%rip), %zmm1, %k0
2398 ; X64-MIC-AVX512F-NEXT: vpcmpneqd .L.str(%rip), %zmm0, %k1
2399 ; X64-MIC-AVX512F-NEXT: kortestw %k0, %k1
2400 ; X64-MIC-AVX512F-NEXT: sete %al
2401 ; X64-MIC-AVX512F-NEXT: vzeroupper
2402 ; X64-MIC-AVX512F-NEXT: retq
2403 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 127) nounwind
2404 %c = icmp eq i32 %m, 0
2408 define i32 @length128(ptr %X, ptr %Y) nounwind {
2409 ; X64-LABEL: length128:
2411 ; X64-NEXT: movl $128, %edx
2412 ; X64-NEXT: jmp memcmp # TAILCALL
2413 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 128) nounwind
2417 define i1 @length128_eq(ptr %x, ptr %y) nounwind {
2418 ; X64-SSE-LABEL: length128_eq:
2420 ; X64-SSE-NEXT: pushq %rax
2421 ; X64-SSE-NEXT: movl $128, %edx
2422 ; X64-SSE-NEXT: callq memcmp
2423 ; X64-SSE-NEXT: testl %eax, %eax
2424 ; X64-SSE-NEXT: setne %al
2425 ; X64-SSE-NEXT: popq %rcx
2426 ; X64-SSE-NEXT: retq
2428 ; X64-AVX1-LABEL: length128_eq:
2429 ; X64-AVX1: # %bb.0:
2430 ; X64-AVX1-NEXT: pushq %rax
2431 ; X64-AVX1-NEXT: movl $128, %edx
2432 ; X64-AVX1-NEXT: callq memcmp
2433 ; X64-AVX1-NEXT: testl %eax, %eax
2434 ; X64-AVX1-NEXT: setne %al
2435 ; X64-AVX1-NEXT: popq %rcx
2436 ; X64-AVX1-NEXT: retq
2438 ; X64-AVX2-LABEL: length128_eq:
2439 ; X64-AVX2: # %bb.0:
2440 ; X64-AVX2-NEXT: pushq %rax
2441 ; X64-AVX2-NEXT: movl $128, %edx
2442 ; X64-AVX2-NEXT: callq memcmp
2443 ; X64-AVX2-NEXT: testl %eax, %eax
2444 ; X64-AVX2-NEXT: setne %al
2445 ; X64-AVX2-NEXT: popq %rcx
2446 ; X64-AVX2-NEXT: retq
2448 ; X64-AVX512BW-LABEL: length128_eq:
2449 ; X64-AVX512BW: # %bb.0:
2450 ; X64-AVX512BW-NEXT: vmovdqu64 (%rdi), %zmm0
2451 ; X64-AVX512BW-NEXT: vmovdqu64 64(%rdi), %zmm1
2452 ; X64-AVX512BW-NEXT: vpcmpneqb 64(%rsi), %zmm1, %k0
2453 ; X64-AVX512BW-NEXT: vpcmpneqb (%rsi), %zmm0, %k1
2454 ; X64-AVX512BW-NEXT: kortestq %k0, %k1
2455 ; X64-AVX512BW-NEXT: setne %al
2456 ; X64-AVX512BW-NEXT: vzeroupper
2457 ; X64-AVX512BW-NEXT: retq
2459 ; X64-AVX512F-LABEL: length128_eq:
2460 ; X64-AVX512F: # %bb.0:
2461 ; X64-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2462 ; X64-AVX512F-NEXT: vmovdqu64 64(%rdi), %zmm1
2463 ; X64-AVX512F-NEXT: vpcmpneqd 64(%rsi), %zmm1, %k0
2464 ; X64-AVX512F-NEXT: vpcmpneqd (%rsi), %zmm0, %k1
2465 ; X64-AVX512F-NEXT: kortestw %k0, %k1
2466 ; X64-AVX512F-NEXT: setne %al
2467 ; X64-AVX512F-NEXT: vzeroupper
2468 ; X64-AVX512F-NEXT: retq
2470 ; X64-MIC-AVX2-LABEL: length128_eq:
2471 ; X64-MIC-AVX2: # %bb.0:
2472 ; X64-MIC-AVX2-NEXT: pushq %rax
2473 ; X64-MIC-AVX2-NEXT: movl $128, %edx
2474 ; X64-MIC-AVX2-NEXT: callq memcmp
2475 ; X64-MIC-AVX2-NEXT: testl %eax, %eax
2476 ; X64-MIC-AVX2-NEXT: setne %al
2477 ; X64-MIC-AVX2-NEXT: popq %rcx
2478 ; X64-MIC-AVX2-NEXT: retq
2480 ; X64-MIC-AVX512F-LABEL: length128_eq:
2481 ; X64-MIC-AVX512F: # %bb.0:
2482 ; X64-MIC-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2483 ; X64-MIC-AVX512F-NEXT: vmovdqu64 64(%rdi), %zmm1
2484 ; X64-MIC-AVX512F-NEXT: vpcmpneqd 64(%rsi), %zmm1, %k0
2485 ; X64-MIC-AVX512F-NEXT: vpcmpneqd (%rsi), %zmm0, %k1
2486 ; X64-MIC-AVX512F-NEXT: kortestw %k0, %k1
2487 ; X64-MIC-AVX512F-NEXT: setne %al
2488 ; X64-MIC-AVX512F-NEXT: vzeroupper
2489 ; X64-MIC-AVX512F-NEXT: retq
2490 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 128) nounwind
2491 %cmp = icmp ne i32 %call, 0
2495 define i1 @length128_lt(ptr %x, ptr %y) nounwind {
2496 ; X64-LABEL: length128_lt:
2498 ; X64-NEXT: pushq %rax
2499 ; X64-NEXT: movl $128, %edx
2500 ; X64-NEXT: callq memcmp
2501 ; X64-NEXT: shrl $31, %eax
2502 ; X64-NEXT: # kill: def $al killed $al killed $eax
2503 ; X64-NEXT: popq %rcx
2505 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 128) nounwind
2506 %cmp = icmp slt i32 %call, 0
2510 define i1 @length128_gt(ptr %x, ptr %y) nounwind {
2511 ; X64-LABEL: length128_gt:
2513 ; X64-NEXT: pushq %rax
2514 ; X64-NEXT: movl $128, %edx
2515 ; X64-NEXT: callq memcmp
2516 ; X64-NEXT: testl %eax, %eax
2517 ; X64-NEXT: setg %al
2518 ; X64-NEXT: popq %rcx
2520 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 128) nounwind
2521 %cmp = icmp sgt i32 %call, 0
2525 define i1 @length128_eq_const(ptr %X) nounwind {
2526 ; X64-SSE-LABEL: length128_eq_const:
2528 ; X64-SSE-NEXT: pushq %rax
2529 ; X64-SSE-NEXT: movl $.L.str, %esi
2530 ; X64-SSE-NEXT: movl $128, %edx
2531 ; X64-SSE-NEXT: callq memcmp
2532 ; X64-SSE-NEXT: testl %eax, %eax
2533 ; X64-SSE-NEXT: sete %al
2534 ; X64-SSE-NEXT: popq %rcx
2535 ; X64-SSE-NEXT: retq
2537 ; X64-AVX1-LABEL: length128_eq_const:
2538 ; X64-AVX1: # %bb.0:
2539 ; X64-AVX1-NEXT: pushq %rax
2540 ; X64-AVX1-NEXT: movl $.L.str, %esi
2541 ; X64-AVX1-NEXT: movl $128, %edx
2542 ; X64-AVX1-NEXT: callq memcmp
2543 ; X64-AVX1-NEXT: testl %eax, %eax
2544 ; X64-AVX1-NEXT: sete %al
2545 ; X64-AVX1-NEXT: popq %rcx
2546 ; X64-AVX1-NEXT: retq
2548 ; X64-AVX2-LABEL: length128_eq_const:
2549 ; X64-AVX2: # %bb.0:
2550 ; X64-AVX2-NEXT: pushq %rax
2551 ; X64-AVX2-NEXT: movl $.L.str, %esi
2552 ; X64-AVX2-NEXT: movl $128, %edx
2553 ; X64-AVX2-NEXT: callq memcmp
2554 ; X64-AVX2-NEXT: testl %eax, %eax
2555 ; X64-AVX2-NEXT: sete %al
2556 ; X64-AVX2-NEXT: popq %rcx
2557 ; X64-AVX2-NEXT: retq
2559 ; X64-AVX512BW-LABEL: length128_eq_const:
2560 ; X64-AVX512BW: # %bb.0:
2561 ; X64-AVX512BW-NEXT: vmovdqu64 (%rdi), %zmm0
2562 ; X64-AVX512BW-NEXT: vmovdqu64 64(%rdi), %zmm1
2563 ; X64-AVX512BW-NEXT: vpcmpneqb .L.str+64(%rip), %zmm1, %k0
2564 ; X64-AVX512BW-NEXT: vpcmpneqb .L.str(%rip), %zmm0, %k1
2565 ; X64-AVX512BW-NEXT: kortestq %k0, %k1
2566 ; X64-AVX512BW-NEXT: sete %al
2567 ; X64-AVX512BW-NEXT: vzeroupper
2568 ; X64-AVX512BW-NEXT: retq
2570 ; X64-AVX512F-LABEL: length128_eq_const:
2571 ; X64-AVX512F: # %bb.0:
2572 ; X64-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2573 ; X64-AVX512F-NEXT: vmovdqu64 64(%rdi), %zmm1
2574 ; X64-AVX512F-NEXT: vpcmpneqd .L.str+64(%rip), %zmm1, %k0
2575 ; X64-AVX512F-NEXT: vpcmpneqd .L.str(%rip), %zmm0, %k1
2576 ; X64-AVX512F-NEXT: kortestw %k0, %k1
2577 ; X64-AVX512F-NEXT: sete %al
2578 ; X64-AVX512F-NEXT: vzeroupper
2579 ; X64-AVX512F-NEXT: retq
2581 ; X64-MIC-AVX2-LABEL: length128_eq_const:
2582 ; X64-MIC-AVX2: # %bb.0:
2583 ; X64-MIC-AVX2-NEXT: pushq %rax
2584 ; X64-MIC-AVX2-NEXT: movl $.L.str, %esi
2585 ; X64-MIC-AVX2-NEXT: movl $128, %edx
2586 ; X64-MIC-AVX2-NEXT: callq memcmp
2587 ; X64-MIC-AVX2-NEXT: testl %eax, %eax
2588 ; X64-MIC-AVX2-NEXT: sete %al
2589 ; X64-MIC-AVX2-NEXT: popq %rcx
2590 ; X64-MIC-AVX2-NEXT: retq
2592 ; X64-MIC-AVX512F-LABEL: length128_eq_const:
2593 ; X64-MIC-AVX512F: # %bb.0:
2594 ; X64-MIC-AVX512F-NEXT: vmovdqu64 (%rdi), %zmm0
2595 ; X64-MIC-AVX512F-NEXT: vmovdqu64 64(%rdi), %zmm1
2596 ; X64-MIC-AVX512F-NEXT: vpcmpneqd .L.str+64(%rip), %zmm1, %k0
2597 ; X64-MIC-AVX512F-NEXT: vpcmpneqd .L.str(%rip), %zmm0, %k1
2598 ; X64-MIC-AVX512F-NEXT: kortestw %k0, %k1
2599 ; X64-MIC-AVX512F-NEXT: sete %al
2600 ; X64-MIC-AVX512F-NEXT: vzeroupper
2601 ; X64-MIC-AVX512F-NEXT: retq
2602 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 128) nounwind
2603 %c = icmp eq i32 %m, 0
2607 define i32 @length192(ptr %X, ptr %Y) nounwind {
2608 ; X64-LABEL: length192:
2610 ; X64-NEXT: movl $192, %edx
2611 ; X64-NEXT: jmp memcmp # TAILCALL
2612 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 192) nounwind
2616 define i1 @length192_eq(ptr %x, ptr %y) nounwind {
2617 ; X64-LABEL: length192_eq:
2619 ; X64-NEXT: pushq %rax
2620 ; X64-NEXT: movl $192, %edx
2621 ; X64-NEXT: callq memcmp
2622 ; X64-NEXT: testl %eax, %eax
2623 ; X64-NEXT: setne %al
2624 ; X64-NEXT: popq %rcx
2626 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 192) nounwind
2627 %cmp = icmp ne i32 %call, 0
2631 define i1 @length192_lt(ptr %x, ptr %y) nounwind {
2632 ; X64-LABEL: length192_lt:
2634 ; X64-NEXT: pushq %rax
2635 ; X64-NEXT: movl $192, %edx
2636 ; X64-NEXT: callq memcmp
2637 ; X64-NEXT: shrl $31, %eax
2638 ; X64-NEXT: # kill: def $al killed $al killed $eax
2639 ; X64-NEXT: popq %rcx
2641 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 192) nounwind
2642 %cmp = icmp slt i32 %call, 0
2646 define i1 @length192_gt(ptr %x, ptr %y) nounwind {
2647 ; X64-LABEL: length192_gt:
2649 ; X64-NEXT: pushq %rax
2650 ; X64-NEXT: movl $192, %edx
2651 ; X64-NEXT: callq memcmp
2652 ; X64-NEXT: testl %eax, %eax
2653 ; X64-NEXT: setg %al
2654 ; X64-NEXT: popq %rcx
2656 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 192) nounwind
2657 %cmp = icmp sgt i32 %call, 0
2661 define i1 @length192_eq_const(ptr %X) nounwind {
2662 ; X64-LABEL: length192_eq_const:
2664 ; X64-NEXT: pushq %rax
2665 ; X64-NEXT: movl $.L.str, %esi
2666 ; X64-NEXT: movl $192, %edx
2667 ; X64-NEXT: callq memcmp
2668 ; X64-NEXT: testl %eax, %eax
2669 ; X64-NEXT: sete %al
2670 ; X64-NEXT: popq %rcx
2672 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 192) nounwind
2673 %c = icmp eq i32 %m, 0
2677 define i32 @length255(ptr %X, ptr %Y) nounwind {
2678 ; X64-LABEL: length255:
2680 ; X64-NEXT: movl $255, %edx
2681 ; X64-NEXT: jmp memcmp # TAILCALL
2682 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 255) nounwind
2686 define i1 @length255_eq(ptr %x, ptr %y) nounwind {
2687 ; X64-LABEL: length255_eq:
2689 ; X64-NEXT: pushq %rax
2690 ; X64-NEXT: movl $255, %edx
2691 ; X64-NEXT: callq memcmp
2692 ; X64-NEXT: testl %eax, %eax
2693 ; X64-NEXT: setne %al
2694 ; X64-NEXT: popq %rcx
2696 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 255) nounwind
2697 %cmp = icmp ne i32 %call, 0
2701 define i1 @length255_lt(ptr %x, ptr %y) nounwind {
2702 ; X64-LABEL: length255_lt:
2704 ; X64-NEXT: pushq %rax
2705 ; X64-NEXT: movl $255, %edx
2706 ; X64-NEXT: callq memcmp
2707 ; X64-NEXT: shrl $31, %eax
2708 ; X64-NEXT: # kill: def $al killed $al killed $eax
2709 ; X64-NEXT: popq %rcx
2711 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 255) nounwind
2712 %cmp = icmp slt i32 %call, 0
2716 define i1 @length255_gt(ptr %x, ptr %y) nounwind {
2717 ; X64-LABEL: length255_gt:
2719 ; X64-NEXT: pushq %rax
2720 ; X64-NEXT: movl $255, %edx
2721 ; X64-NEXT: callq memcmp
2722 ; X64-NEXT: testl %eax, %eax
2723 ; X64-NEXT: setg %al
2724 ; X64-NEXT: popq %rcx
2726 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 255) nounwind
2727 %cmp = icmp sgt i32 %call, 0
2731 define i1 @length255_eq_const(ptr %X) nounwind {
2732 ; X64-LABEL: length255_eq_const:
2734 ; X64-NEXT: pushq %rax
2735 ; X64-NEXT: movl $.L.str, %esi
2736 ; X64-NEXT: movl $255, %edx
2737 ; X64-NEXT: callq memcmp
2738 ; X64-NEXT: testl %eax, %eax
2739 ; X64-NEXT: sete %al
2740 ; X64-NEXT: popq %rcx
2742 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 255) nounwind
2743 %c = icmp eq i32 %m, 0
2747 define i32 @length256(ptr %X, ptr %Y) nounwind {
2748 ; X64-LABEL: length256:
2750 ; X64-NEXT: movl $256, %edx # imm = 0x100
2751 ; X64-NEXT: jmp memcmp # TAILCALL
2752 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 256) nounwind
2756 define i1 @length256_eq(ptr %x, ptr %y) nounwind {
2757 ; X64-LABEL: length256_eq:
2759 ; X64-NEXT: pushq %rax
2760 ; X64-NEXT: movl $256, %edx # imm = 0x100
2761 ; X64-NEXT: callq memcmp
2762 ; X64-NEXT: testl %eax, %eax
2763 ; X64-NEXT: setne %al
2764 ; X64-NEXT: popq %rcx
2766 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 256) nounwind
2767 %cmp = icmp ne i32 %call, 0
2771 define i1 @length256_lt(ptr %x, ptr %y) nounwind {
2772 ; X64-LABEL: length256_lt:
2774 ; X64-NEXT: pushq %rax
2775 ; X64-NEXT: movl $256, %edx # imm = 0x100
2776 ; X64-NEXT: callq memcmp
2777 ; X64-NEXT: shrl $31, %eax
2778 ; X64-NEXT: # kill: def $al killed $al killed $eax
2779 ; X64-NEXT: popq %rcx
2781 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 256) nounwind
2782 %cmp = icmp slt i32 %call, 0
2786 define i1 @length256_gt(ptr %x, ptr %y) nounwind {
2787 ; X64-LABEL: length256_gt:
2789 ; X64-NEXT: pushq %rax
2790 ; X64-NEXT: movl $256, %edx # imm = 0x100
2791 ; X64-NEXT: callq memcmp
2792 ; X64-NEXT: testl %eax, %eax
2793 ; X64-NEXT: setg %al
2794 ; X64-NEXT: popq %rcx
2796 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 256) nounwind
2797 %cmp = icmp sgt i32 %call, 0
2801 define i1 @length256_eq_const(ptr %X) nounwind {
2802 ; X64-LABEL: length256_eq_const:
2804 ; X64-NEXT: pushq %rax
2805 ; X64-NEXT: movl $.L.str, %esi
2806 ; X64-NEXT: movl $256, %edx # imm = 0x100
2807 ; X64-NEXT: callq memcmp
2808 ; X64-NEXT: testl %eax, %eax
2809 ; X64-NEXT: sete %al
2810 ; X64-NEXT: popq %rcx
2812 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 256) nounwind
2813 %c = icmp eq i32 %m, 0
2817 define i32 @length384(ptr %X, ptr %Y) nounwind {
2818 ; X64-LABEL: length384:
2820 ; X64-NEXT: movl $384, %edx # imm = 0x180
2821 ; X64-NEXT: jmp memcmp # TAILCALL
2822 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 384) nounwind
2826 define i1 @length384_eq(ptr %x, ptr %y) nounwind {
2827 ; X64-LABEL: length384_eq:
2829 ; X64-NEXT: pushq %rax
2830 ; X64-NEXT: movl $384, %edx # imm = 0x180
2831 ; X64-NEXT: callq memcmp
2832 ; X64-NEXT: testl %eax, %eax
2833 ; X64-NEXT: setne %al
2834 ; X64-NEXT: popq %rcx
2836 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 384) nounwind
2837 %cmp = icmp ne i32 %call, 0
2841 define i1 @length384_lt(ptr %x, ptr %y) nounwind {
2842 ; X64-LABEL: length384_lt:
2844 ; X64-NEXT: pushq %rax
2845 ; X64-NEXT: movl $384, %edx # imm = 0x180
2846 ; X64-NEXT: callq memcmp
2847 ; X64-NEXT: shrl $31, %eax
2848 ; X64-NEXT: # kill: def $al killed $al killed $eax
2849 ; X64-NEXT: popq %rcx
2851 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 384) nounwind
2852 %cmp = icmp slt i32 %call, 0
2856 define i1 @length384_gt(ptr %x, ptr %y) nounwind {
2857 ; X64-LABEL: length384_gt:
2859 ; X64-NEXT: pushq %rax
2860 ; X64-NEXT: movl $384, %edx # imm = 0x180
2861 ; X64-NEXT: callq memcmp
2862 ; X64-NEXT: testl %eax, %eax
2863 ; X64-NEXT: setg %al
2864 ; X64-NEXT: popq %rcx
2866 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 384) nounwind
2867 %cmp = icmp sgt i32 %call, 0
2871 define i1 @length384_eq_const(ptr %X) nounwind {
2872 ; X64-LABEL: length384_eq_const:
2874 ; X64-NEXT: pushq %rax
2875 ; X64-NEXT: movl $.L.str, %esi
2876 ; X64-NEXT: movl $384, %edx # imm = 0x180
2877 ; X64-NEXT: callq memcmp
2878 ; X64-NEXT: testl %eax, %eax
2879 ; X64-NEXT: sete %al
2880 ; X64-NEXT: popq %rcx
2882 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 384) nounwind
2883 %c = icmp eq i32 %m, 0
2887 define i32 @length511(ptr %X, ptr %Y) nounwind {
2888 ; X64-LABEL: length511:
2890 ; X64-NEXT: movl $511, %edx # imm = 0x1FF
2891 ; X64-NEXT: jmp memcmp # TAILCALL
2892 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 511) nounwind
2896 define i1 @length511_eq(ptr %x, ptr %y) nounwind {
2897 ; X64-LABEL: length511_eq:
2899 ; X64-NEXT: pushq %rax
2900 ; X64-NEXT: movl $511, %edx # imm = 0x1FF
2901 ; X64-NEXT: callq memcmp
2902 ; X64-NEXT: testl %eax, %eax
2903 ; X64-NEXT: setne %al
2904 ; X64-NEXT: popq %rcx
2906 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 511) nounwind
2907 %cmp = icmp ne i32 %call, 0
2911 define i1 @length511_lt(ptr %x, ptr %y) nounwind {
2912 ; X64-LABEL: length511_lt:
2914 ; X64-NEXT: pushq %rax
2915 ; X64-NEXT: movl $511, %edx # imm = 0x1FF
2916 ; X64-NEXT: callq memcmp
2917 ; X64-NEXT: shrl $31, %eax
2918 ; X64-NEXT: # kill: def $al killed $al killed $eax
2919 ; X64-NEXT: popq %rcx
2921 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 511) nounwind
2922 %cmp = icmp slt i32 %call, 0
2926 define i1 @length511_gt(ptr %x, ptr %y) nounwind {
2927 ; X64-LABEL: length511_gt:
2929 ; X64-NEXT: pushq %rax
2930 ; X64-NEXT: movl $511, %edx # imm = 0x1FF
2931 ; X64-NEXT: callq memcmp
2932 ; X64-NEXT: testl %eax, %eax
2933 ; X64-NEXT: setg %al
2934 ; X64-NEXT: popq %rcx
2936 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 511) nounwind
2937 %cmp = icmp sgt i32 %call, 0
2941 define i1 @length511_eq_const(ptr %X) nounwind {
2942 ; X64-LABEL: length511_eq_const:
2944 ; X64-NEXT: pushq %rax
2945 ; X64-NEXT: movl $.L.str, %esi
2946 ; X64-NEXT: movl $511, %edx # imm = 0x1FF
2947 ; X64-NEXT: callq memcmp
2948 ; X64-NEXT: testl %eax, %eax
2949 ; X64-NEXT: sete %al
2950 ; X64-NEXT: popq %rcx
2952 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 511) nounwind
2953 %c = icmp eq i32 %m, 0
2957 define i32 @length512(ptr %X, ptr %Y) nounwind {
2958 ; X64-LABEL: length512:
2960 ; X64-NEXT: movl $512, %edx # imm = 0x200
2961 ; X64-NEXT: jmp memcmp # TAILCALL
2962 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 512) nounwind
2966 define i1 @length512_eq(ptr %x, ptr %y) nounwind {
2967 ; X64-LABEL: length512_eq:
2969 ; X64-NEXT: pushq %rax
2970 ; X64-NEXT: movl $512, %edx # imm = 0x200
2971 ; X64-NEXT: callq memcmp
2972 ; X64-NEXT: testl %eax, %eax
2973 ; X64-NEXT: setne %al
2974 ; X64-NEXT: popq %rcx
2976 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 512) nounwind
2977 %cmp = icmp ne i32 %call, 0
2981 define i1 @length512_lt(ptr %x, ptr %y) nounwind {
2982 ; X64-LABEL: length512_lt:
2984 ; X64-NEXT: pushq %rax
2985 ; X64-NEXT: movl $512, %edx # imm = 0x200
2986 ; X64-NEXT: callq memcmp
2987 ; X64-NEXT: shrl $31, %eax
2988 ; X64-NEXT: # kill: def $al killed $al killed $eax
2989 ; X64-NEXT: popq %rcx
2991 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 512) nounwind
2992 %cmp = icmp slt i32 %call, 0
2996 define i1 @length512_gt(ptr %x, ptr %y) nounwind {
2997 ; X64-LABEL: length512_gt:
2999 ; X64-NEXT: pushq %rax
3000 ; X64-NEXT: movl $512, %edx # imm = 0x200
3001 ; X64-NEXT: callq memcmp
3002 ; X64-NEXT: testl %eax, %eax
3003 ; X64-NEXT: setg %al
3004 ; X64-NEXT: popq %rcx
3006 %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 512) nounwind
3007 %cmp = icmp sgt i32 %call, 0
3011 define i1 @length512_eq_const(ptr %X) nounwind {
3012 ; X64-LABEL: length512_eq_const:
3014 ; X64-NEXT: pushq %rax
3015 ; X64-NEXT: movl $.L.str, %esi
3016 ; X64-NEXT: movl $512, %edx # imm = 0x200
3017 ; X64-NEXT: callq memcmp
3018 ; X64-NEXT: testl %eax, %eax
3019 ; X64-NEXT: sete %al
3020 ; X64-NEXT: popq %rcx
3022 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 512) nounwind
3023 %c = icmp eq i32 %m, 0
3027 ; This checks that we do not do stupid things with huge sizes.
3028 define i32 @huge_length(ptr %X, ptr %Y) nounwind {
3029 ; X64-LABEL: huge_length:
3031 ; X64-NEXT: movabsq $9223372036854775807, %rdx # imm = 0x7FFFFFFFFFFFFFFF
3032 ; X64-NEXT: jmp memcmp # TAILCALL
3033 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 9223372036854775807) nounwind
3037 define i1 @huge_length_eq(ptr %X, ptr %Y) nounwind {
3038 ; X64-LABEL: huge_length_eq:
3040 ; X64-NEXT: pushq %rax
3041 ; X64-NEXT: movabsq $9223372036854775807, %rdx # imm = 0x7FFFFFFFFFFFFFFF
3042 ; X64-NEXT: callq memcmp
3043 ; X64-NEXT: testl %eax, %eax
3044 ; X64-NEXT: sete %al
3045 ; X64-NEXT: popq %rcx
3047 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 9223372036854775807) nounwind
3048 %c = icmp eq i32 %m, 0
3052 ; This checks non-constant sizes.
3053 define i32 @nonconst_length(ptr %X, ptr %Y, i64 %size) nounwind {
3054 ; X64-LABEL: nonconst_length:
3056 ; X64-NEXT: jmp memcmp # TAILCALL
3057 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 %size) nounwind
3061 define i1 @nonconst_length_eq(ptr %X, ptr %Y, i64 %size) nounwind {
3062 ; X64-LABEL: nonconst_length_eq:
3064 ; X64-NEXT: pushq %rax
3065 ; X64-NEXT: callq memcmp
3066 ; X64-NEXT: testl %eax, %eax
3067 ; X64-NEXT: sete %al
3068 ; X64-NEXT: popq %rcx
3070 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 %size) nounwind
3071 %c = icmp eq i32 %m, 0