1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=cmov | FileCheck %s --check-prefix=X86 --check-prefix=X86-NOSSE
3 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86 --check-prefix=X86-SSE2
5 ; This tests codegen time inlining/optimization of memcmp
8 @.str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 1
10 declare dso_local i32 @memcmp(ptr, ptr, i32)
11 declare dso_local i32 @bcmp(ptr, ptr, i32)
13 define i32 @length2(ptr %X, ptr %Y) nounwind optsize {
16 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
17 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
18 ; X86-NEXT: movzwl (%ecx), %ecx
19 ; X86-NEXT: movzwl (%eax), %edx
20 ; X86-NEXT: rolw $8, %cx
21 ; X86-NEXT: rolw $8, %dx
22 ; X86-NEXT: movzwl %cx, %eax
23 ; X86-NEXT: movzwl %dx, %ecx
24 ; X86-NEXT: subl %ecx, %eax
26 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind
30 define i1 @length2_eq(ptr %X, ptr %Y) nounwind optsize {
31 ; X86-LABEL: length2_eq:
33 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
34 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
35 ; X86-NEXT: movzwl (%ecx), %ecx
36 ; X86-NEXT: cmpw (%eax), %cx
39 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind
40 %c = icmp eq i32 %m, 0
44 define i1 @length2_eq_const(ptr %X) nounwind optsize {
45 ; X86-LABEL: length2_eq_const:
47 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
48 ; X86-NEXT: movzwl (%eax), %eax
49 ; X86-NEXT: cmpl $12849, %eax # imm = 0x3231
52 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([65 x i8], ptr @.str, i32 0, i32 1), i32 2) nounwind
53 %c = icmp ne i32 %m, 0
57 define i1 @length2_eq_nobuiltin_attr(ptr %X, ptr %Y) nounwind optsize {
58 ; X86-LABEL: length2_eq_nobuiltin_attr:
61 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
62 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
63 ; X86-NEXT: calll memcmp
64 ; X86-NEXT: addl $12, %esp
65 ; X86-NEXT: testl %eax, %eax
68 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind nobuiltin
69 %c = icmp eq i32 %m, 0
73 define i32 @length3(ptr %X, ptr %Y) nounwind optsize {
76 ; X86-NEXT: pushl %esi
77 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
78 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
79 ; X86-NEXT: movzwl (%eax), %edx
80 ; X86-NEXT: movzwl (%ecx), %esi
81 ; X86-NEXT: rolw $8, %dx
82 ; X86-NEXT: rolw $8, %si
83 ; X86-NEXT: cmpw %si, %dx
84 ; X86-NEXT: jne .LBB4_3
85 ; X86-NEXT: # %bb.1: # %loadbb1
86 ; X86-NEXT: movzbl 2(%eax), %eax
87 ; X86-NEXT: movzbl 2(%ecx), %ecx
88 ; X86-NEXT: subl %ecx, %eax
89 ; X86-NEXT: jmp .LBB4_2
90 ; X86-NEXT: .LBB4_3: # %res_block
91 ; X86-NEXT: xorl %eax, %eax
92 ; X86-NEXT: cmpw %si, %dx
93 ; X86-NEXT: sbbl %eax, %eax
94 ; X86-NEXT: orl $1, %eax
95 ; X86-NEXT: .LBB4_2: # %endblock
98 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 3) nounwind
102 define i1 @length3_eq(ptr %X, ptr %Y) nounwind optsize {
103 ; X86-LABEL: length3_eq:
105 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
106 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
107 ; X86-NEXT: movzwl (%ecx), %edx
108 ; X86-NEXT: xorw (%eax), %dx
109 ; X86-NEXT: movb 2(%ecx), %cl
110 ; X86-NEXT: xorb 2(%eax), %cl
111 ; X86-NEXT: movzbl %cl, %eax
112 ; X86-NEXT: orw %dx, %ax
113 ; X86-NEXT: setne %al
115 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 3) nounwind
116 %c = icmp ne i32 %m, 0
120 define i32 @length4(ptr %X, ptr %Y) nounwind optsize {
121 ; X86-LABEL: length4:
123 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
124 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
125 ; X86-NEXT: movl (%ecx), %ecx
126 ; X86-NEXT: movl (%eax), %edx
127 ; X86-NEXT: bswapl %ecx
128 ; X86-NEXT: bswapl %edx
129 ; X86-NEXT: xorl %eax, %eax
130 ; X86-NEXT: cmpl %edx, %ecx
132 ; X86-NEXT: sbbl $0, %eax
134 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 4) nounwind
138 define i1 @length4_eq(ptr %X, ptr %Y) nounwind optsize {
139 ; X86-LABEL: length4_eq:
141 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
142 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
143 ; X86-NEXT: movl (%ecx), %ecx
144 ; X86-NEXT: cmpl (%eax), %ecx
145 ; X86-NEXT: setne %al
147 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 4) nounwind
148 %c = icmp ne i32 %m, 0
152 define i1 @length4_eq_const(ptr %X) nounwind optsize {
153 ; X86-LABEL: length4_eq_const:
155 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
156 ; X86-NEXT: cmpl $875770417, (%eax) # imm = 0x34333231
159 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([65 x i8], ptr @.str, i32 0, i32 1), i32 4) nounwind
160 %c = icmp eq i32 %m, 0
164 define i32 @length5(ptr %X, ptr %Y) nounwind optsize {
165 ; X86-LABEL: length5:
167 ; X86-NEXT: pushl %esi
168 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
169 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
170 ; X86-NEXT: movl (%eax), %edx
171 ; X86-NEXT: movl (%ecx), %esi
172 ; X86-NEXT: bswapl %edx
173 ; X86-NEXT: bswapl %esi
174 ; X86-NEXT: cmpl %esi, %edx
175 ; X86-NEXT: jne .LBB9_3
176 ; X86-NEXT: # %bb.1: # %loadbb1
177 ; X86-NEXT: movzbl 4(%eax), %eax
178 ; X86-NEXT: movzbl 4(%ecx), %ecx
179 ; X86-NEXT: subl %ecx, %eax
180 ; X86-NEXT: jmp .LBB9_2
181 ; X86-NEXT: .LBB9_3: # %res_block
182 ; X86-NEXT: xorl %eax, %eax
183 ; X86-NEXT: cmpl %esi, %edx
184 ; X86-NEXT: sbbl %eax, %eax
185 ; X86-NEXT: orl $1, %eax
186 ; X86-NEXT: .LBB9_2: # %endblock
187 ; X86-NEXT: popl %esi
189 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 5) nounwind
193 define i1 @length5_eq(ptr %X, ptr %Y) nounwind optsize {
194 ; X86-LABEL: length5_eq:
196 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
197 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
198 ; X86-NEXT: movl (%ecx), %edx
199 ; X86-NEXT: xorl (%eax), %edx
200 ; X86-NEXT: movb 4(%ecx), %cl
201 ; X86-NEXT: xorb 4(%eax), %cl
202 ; X86-NEXT: movzbl %cl, %eax
203 ; X86-NEXT: orl %edx, %eax
204 ; X86-NEXT: setne %al
206 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 5) nounwind
207 %c = icmp ne i32 %m, 0
211 define i32 @length8(ptr %X, ptr %Y) nounwind optsize {
212 ; X86-LABEL: length8:
214 ; X86-NEXT: pushl %esi
215 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
216 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
217 ; X86-NEXT: movl (%esi), %ecx
218 ; X86-NEXT: movl (%eax), %edx
219 ; X86-NEXT: bswapl %ecx
220 ; X86-NEXT: bswapl %edx
221 ; X86-NEXT: cmpl %edx, %ecx
222 ; X86-NEXT: jne .LBB11_2
223 ; X86-NEXT: # %bb.1: # %loadbb1
224 ; X86-NEXT: movl 4(%esi), %ecx
225 ; X86-NEXT: movl 4(%eax), %edx
226 ; X86-NEXT: bswapl %ecx
227 ; X86-NEXT: bswapl %edx
228 ; X86-NEXT: xorl %eax, %eax
229 ; X86-NEXT: cmpl %edx, %ecx
230 ; X86-NEXT: je .LBB11_3
231 ; X86-NEXT: .LBB11_2: # %res_block
232 ; X86-NEXT: xorl %eax, %eax
233 ; X86-NEXT: cmpl %edx, %ecx
234 ; X86-NEXT: sbbl %eax, %eax
235 ; X86-NEXT: orl $1, %eax
236 ; X86-NEXT: .LBB11_3: # %endblock
237 ; X86-NEXT: popl %esi
239 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 8) nounwind
243 define i1 @length8_eq(ptr %X, ptr %Y) nounwind optsize {
244 ; X86-LABEL: length8_eq:
246 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
247 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
248 ; X86-NEXT: movl (%ecx), %edx
249 ; X86-NEXT: movl 4(%ecx), %ecx
250 ; X86-NEXT: xorl (%eax), %edx
251 ; X86-NEXT: xorl 4(%eax), %ecx
252 ; X86-NEXT: orl %edx, %ecx
255 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 8) nounwind
256 %c = icmp eq i32 %m, 0
260 define i1 @length8_eq_const(ptr %X) nounwind optsize {
261 ; X86-LABEL: length8_eq_const:
263 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
264 ; X86-NEXT: movl $858927408, %ecx # imm = 0x33323130
265 ; X86-NEXT: xorl (%eax), %ecx
266 ; X86-NEXT: movl $926299444, %edx # imm = 0x37363534
267 ; X86-NEXT: xorl 4(%eax), %edx
268 ; X86-NEXT: orl %ecx, %edx
269 ; X86-NEXT: setne %al
271 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 8) nounwind
272 %c = icmp ne i32 %m, 0
276 define i1 @length12_eq(ptr %X, ptr %Y) nounwind optsize {
277 ; X86-LABEL: length12_eq:
279 ; X86-NEXT: pushl $12
280 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
281 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
282 ; X86-NEXT: calll memcmp
283 ; X86-NEXT: addl $12, %esp
284 ; X86-NEXT: testl %eax, %eax
285 ; X86-NEXT: setne %al
287 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 12) nounwind
288 %c = icmp ne i32 %m, 0
292 define i32 @length12(ptr %X, ptr %Y) nounwind optsize {
293 ; X86-LABEL: length12:
295 ; X86-NEXT: pushl $12
296 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
297 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
298 ; X86-NEXT: calll memcmp
299 ; X86-NEXT: addl $12, %esp
301 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 12) nounwind
305 ; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329
307 define i32 @length16(ptr %X, ptr %Y) nounwind optsize {
308 ; X86-LABEL: length16:
310 ; X86-NEXT: pushl $16
311 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
312 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
313 ; X86-NEXT: calll memcmp
314 ; X86-NEXT: addl $12, %esp
316 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 16) nounwind
320 define i1 @length16_eq(ptr %x, ptr %y) nounwind optsize {
321 ; X86-NOSSE-LABEL: length16_eq:
322 ; X86-NOSSE: # %bb.0:
323 ; X86-NOSSE-NEXT: pushl $16
324 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
325 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
326 ; X86-NOSSE-NEXT: calll memcmp
327 ; X86-NOSSE-NEXT: addl $12, %esp
328 ; X86-NOSSE-NEXT: testl %eax, %eax
329 ; X86-NOSSE-NEXT: setne %al
330 ; X86-NOSSE-NEXT: retl
332 ; X86-SSE2-LABEL: length16_eq:
334 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
335 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
336 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
337 ; X86-SSE2-NEXT: movdqu (%eax), %xmm1
338 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm1
339 ; X86-SSE2-NEXT: pmovmskb %xmm1, %eax
340 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
341 ; X86-SSE2-NEXT: setne %al
342 ; X86-SSE2-NEXT: retl
343 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 16) nounwind
344 %cmp = icmp ne i32 %call, 0
348 define i1 @length16_eq_const(ptr %X) nounwind optsize {
349 ; X86-NOSSE-LABEL: length16_eq_const:
350 ; X86-NOSSE: # %bb.0:
351 ; X86-NOSSE-NEXT: pushl $16
352 ; X86-NOSSE-NEXT: pushl $.L.str
353 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
354 ; X86-NOSSE-NEXT: calll memcmp
355 ; X86-NOSSE-NEXT: addl $12, %esp
356 ; X86-NOSSE-NEXT: testl %eax, %eax
357 ; X86-NOSSE-NEXT: sete %al
358 ; X86-NOSSE-NEXT: retl
360 ; X86-SSE2-LABEL: length16_eq_const:
362 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
363 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
364 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
365 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
366 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
367 ; X86-SSE2-NEXT: sete %al
368 ; X86-SSE2-NEXT: retl
369 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 16) nounwind
370 %c = icmp eq i32 %m, 0
374 ; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914
376 define i32 @length24(ptr %X, ptr %Y) nounwind optsize {
377 ; X86-LABEL: length24:
379 ; X86-NEXT: pushl $24
380 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
381 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
382 ; X86-NEXT: calll memcmp
383 ; X86-NEXT: addl $12, %esp
385 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 24) nounwind
389 define i1 @length24_eq(ptr %x, ptr %y) nounwind optsize {
390 ; X86-NOSSE-LABEL: length24_eq:
391 ; X86-NOSSE: # %bb.0:
392 ; X86-NOSSE-NEXT: pushl $24
393 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
394 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
395 ; X86-NOSSE-NEXT: calll memcmp
396 ; X86-NOSSE-NEXT: addl $12, %esp
397 ; X86-NOSSE-NEXT: testl %eax, %eax
398 ; X86-NOSSE-NEXT: sete %al
399 ; X86-NOSSE-NEXT: retl
401 ; X86-SSE2-LABEL: length24_eq:
403 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
404 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
405 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
406 ; X86-SSE2-NEXT: movdqu 8(%ecx), %xmm1
407 ; X86-SSE2-NEXT: movdqu (%eax), %xmm2
408 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
409 ; X86-SSE2-NEXT: movdqu 8(%eax), %xmm0
410 ; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
411 ; X86-SSE2-NEXT: pand %xmm2, %xmm0
412 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
413 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
414 ; X86-SSE2-NEXT: sete %al
415 ; X86-SSE2-NEXT: retl
416 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 24) nounwind
417 %cmp = icmp eq i32 %call, 0
421 define i1 @length24_eq_const(ptr %X) nounwind optsize {
422 ; X86-NOSSE-LABEL: length24_eq_const:
423 ; X86-NOSSE: # %bb.0:
424 ; X86-NOSSE-NEXT: pushl $24
425 ; X86-NOSSE-NEXT: pushl $.L.str
426 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
427 ; X86-NOSSE-NEXT: calll memcmp
428 ; X86-NOSSE-NEXT: addl $12, %esp
429 ; X86-NOSSE-NEXT: testl %eax, %eax
430 ; X86-NOSSE-NEXT: setne %al
431 ; X86-NOSSE-NEXT: retl
433 ; X86-SSE2-LABEL: length24_eq_const:
435 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
436 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
437 ; X86-SSE2-NEXT: movdqu 8(%eax), %xmm1
438 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
439 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
440 ; X86-SSE2-NEXT: pand %xmm1, %xmm0
441 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
442 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
443 ; X86-SSE2-NEXT: setne %al
444 ; X86-SSE2-NEXT: retl
445 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 24) nounwind
446 %c = icmp ne i32 %m, 0
450 define i32 @length32(ptr %X, ptr %Y) nounwind optsize {
451 ; X86-LABEL: length32:
453 ; X86-NEXT: pushl $32
454 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
455 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
456 ; X86-NEXT: calll memcmp
457 ; X86-NEXT: addl $12, %esp
459 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 32) nounwind
463 ; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325
465 define i1 @length32_eq(ptr %x, ptr %y) nounwind optsize {
466 ; X86-NOSSE-LABEL: length32_eq:
467 ; X86-NOSSE: # %bb.0:
468 ; X86-NOSSE-NEXT: pushl $32
469 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
470 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
471 ; X86-NOSSE-NEXT: calll memcmp
472 ; X86-NOSSE-NEXT: addl $12, %esp
473 ; X86-NOSSE-NEXT: testl %eax, %eax
474 ; X86-NOSSE-NEXT: sete %al
475 ; X86-NOSSE-NEXT: retl
477 ; X86-SSE2-LABEL: length32_eq:
479 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
480 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx
481 ; X86-SSE2-NEXT: movdqu (%ecx), %xmm0
482 ; X86-SSE2-NEXT: movdqu 16(%ecx), %xmm1
483 ; X86-SSE2-NEXT: movdqu (%eax), %xmm2
484 ; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2
485 ; X86-SSE2-NEXT: movdqu 16(%eax), %xmm0
486 ; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0
487 ; X86-SSE2-NEXT: pand %xmm2, %xmm0
488 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
489 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
490 ; X86-SSE2-NEXT: sete %al
491 ; X86-SSE2-NEXT: retl
492 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 32) nounwind
493 %cmp = icmp eq i32 %call, 0
497 define i1 @length32_eq_const(ptr %X) nounwind optsize {
498 ; X86-NOSSE-LABEL: length32_eq_const:
499 ; X86-NOSSE: # %bb.0:
500 ; X86-NOSSE-NEXT: pushl $32
501 ; X86-NOSSE-NEXT: pushl $.L.str
502 ; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)
503 ; X86-NOSSE-NEXT: calll memcmp
504 ; X86-NOSSE-NEXT: addl $12, %esp
505 ; X86-NOSSE-NEXT: testl %eax, %eax
506 ; X86-NOSSE-NEXT: setne %al
507 ; X86-NOSSE-NEXT: retl
509 ; X86-SSE2-LABEL: length32_eq_const:
511 ; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax
512 ; X86-SSE2-NEXT: movdqu (%eax), %xmm0
513 ; X86-SSE2-NEXT: movdqu 16(%eax), %xmm1
514 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1
515 ; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0
516 ; X86-SSE2-NEXT: pand %xmm1, %xmm0
517 ; X86-SSE2-NEXT: pmovmskb %xmm0, %eax
518 ; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF
519 ; X86-SSE2-NEXT: setne %al
520 ; X86-SSE2-NEXT: retl
521 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 32) nounwind
522 %c = icmp ne i32 %m, 0
526 define i32 @length64(ptr %X, ptr %Y) nounwind optsize {
527 ; X86-LABEL: length64:
529 ; X86-NEXT: pushl $64
530 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
531 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
532 ; X86-NEXT: calll memcmp
533 ; X86-NEXT: addl $12, %esp
535 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 64) nounwind
539 define i1 @length64_eq(ptr %x, ptr %y) nounwind optsize {
540 ; X86-LABEL: length64_eq:
542 ; X86-NEXT: pushl $64
543 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
544 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
545 ; X86-NEXT: calll memcmp
546 ; X86-NEXT: addl $12, %esp
547 ; X86-NEXT: testl %eax, %eax
548 ; X86-NEXT: setne %al
550 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 64) nounwind
551 %cmp = icmp ne i32 %call, 0
555 define i1 @length64_eq_const(ptr %X) nounwind optsize {
556 ; X86-LABEL: length64_eq_const:
558 ; X86-NEXT: pushl $64
559 ; X86-NEXT: pushl $.L.str
560 ; X86-NEXT: pushl {{[0-9]+}}(%esp)
561 ; X86-NEXT: calll memcmp
562 ; X86-NEXT: addl $12, %esp
563 ; X86-NEXT: testl %eax, %eax
566 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 64) nounwind
567 %c = icmp eq i32 %m, 0
571 define i32 @bcmp_length2(ptr %X, ptr %Y) nounwind optsize {
572 ; X86-LABEL: bcmp_length2:
574 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
575 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
576 ; X86-NEXT: movzwl (%eax), %edx
577 ; X86-NEXT: xorl %eax, %eax
578 ; X86-NEXT: cmpw (%ecx), %dx
579 ; X86-NEXT: setne %al
581 %m = tail call i32 @bcmp(ptr %X, ptr %Y, i32 2) nounwind