blob: 8a8b180a29e55c7965aab1c85a31a18c2045009c [file] [log] [blame]
Varvara Rainchika020a242014-04-29 17:44:56 +04001/*
2Copyright (c) 2014, Intel Corporation
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10
11 * Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14
15 * Neither the name of Intel Corporation nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*/
30
31#include "cache.h"
32
33#ifndef MEMCMP
34# define MEMCMP memcmp
35#endif
36
37#ifndef L
38# define L(label) .L##label
39#endif
40
41#ifndef ALIGN
42# define ALIGN(n) .p2align n
43#endif
44
45#ifndef cfi_startproc
46# define cfi_startproc .cfi_startproc
47#endif
48
49#ifndef cfi_endproc
50# define cfi_endproc .cfi_endproc
51#endif
52
53#ifndef ENTRY
54# define ENTRY(name) \
55 .type name, @function; \
56 .globl name; \
57 .p2align 4; \
58name: \
59 cfi_startproc
60#endif
61
62#ifndef END
63# define END(name) \
64 cfi_endproc; \
65 .size name, .-name
66#endif
67
68#ifndef ALIGN
69# define ALIGN(n) .p2align n
70#endif
71
72#define JMPTBL(I, B) (I - B)
73
74#define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE) \
75 lea TABLE(%rip), %r11; \
76 movslq (%r11, INDEX, SCALE), %rcx; \
77 add %r11, %rcx; \
78 jmp *%rcx; \
79 ud2
80
81 .section .text.sse4.1,"ax",@progbits
82ENTRY (MEMCMP)
83#ifdef USE_AS_WMEMCMP
84 shl $2, %rdx
85#endif
86 pxor %xmm0, %xmm0
87 cmp $79, %rdx
88 ja L(79bytesormore)
89#ifndef USE_AS_WMEMCMP
90 cmp $1, %rdx
91 je L(firstbyte)
92#endif
93 add %rdx, %rsi
94 add %rdx, %rdi
95 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
96
97#ifndef USE_AS_WMEMCMP
98 ALIGN (4)
99L(firstbyte):
100 movzbl (%rdi), %eax
101 movzbl (%rsi), %ecx
102 sub %ecx, %eax
103 ret
104#endif
105
106 ALIGN (4)
107L(79bytesormore):
108 movdqu (%rsi), %xmm1
109 movdqu (%rdi), %xmm2
110 pxor %xmm1, %xmm2
111 ptest %xmm2, %xmm0
112 jnc L(16bytesin256)
113 mov %rsi, %rcx
114 and $-16, %rsi
115 add $16, %rsi
116 sub %rsi, %rcx
117
118 sub %rcx, %rdi
119 add %rcx, %rdx
120 test $0xf, %rdi
121 jz L(2aligned)
122
123 cmp $128, %rdx
124 ja L(128bytesormore)
125L(less128bytes):
126 sub $64, %rdx
127
128 movdqu (%rdi), %xmm2
129 pxor (%rsi), %xmm2
130 ptest %xmm2, %xmm0
131 jnc L(16bytesin256)
132
133 movdqu 16(%rdi), %xmm2
134 pxor 16(%rsi), %xmm2
135 ptest %xmm2, %xmm0
136 jnc L(32bytesin256)
137
138 movdqu 32(%rdi), %xmm2
139 pxor 32(%rsi), %xmm2
140 ptest %xmm2, %xmm0
141 jnc L(48bytesin256)
142
143 movdqu 48(%rdi), %xmm2
144 pxor 48(%rsi), %xmm2
145 ptest %xmm2, %xmm0
146 jnc L(64bytesin256)
147 cmp $32, %rdx
148 jb L(less32bytesin64)
149
150 movdqu 64(%rdi), %xmm2
151 pxor 64(%rsi), %xmm2
152 ptest %xmm2, %xmm0
153 jnc L(80bytesin256)
154
155 movdqu 80(%rdi), %xmm2
156 pxor 80(%rsi), %xmm2
157 ptest %xmm2, %xmm0
158 jnc L(96bytesin256)
159 sub $32, %rdx
160 add $32, %rdi
161 add $32, %rsi
162L(less32bytesin64):
163 add $64, %rdi
164 add $64, %rsi
165 add %rdx, %rsi
166 add %rdx, %rdi
167 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
168
169L(128bytesormore):
170 cmp $512, %rdx
171 ja L(512bytesormore)
172 cmp $256, %rdx
173 ja L(less512bytes)
174L(less256bytes):
175 sub $128, %rdx
176
177 movdqu (%rdi), %xmm2
178 pxor (%rsi), %xmm2
179 ptest %xmm2, %xmm0
180 jnc L(16bytesin256)
181
182 movdqu 16(%rdi), %xmm2
183 pxor 16(%rsi), %xmm2
184 ptest %xmm2, %xmm0
185 jnc L(32bytesin256)
186
187 movdqu 32(%rdi), %xmm2
188 pxor 32(%rsi), %xmm2
189 ptest %xmm2, %xmm0
190 jnc L(48bytesin256)
191
192 movdqu 48(%rdi), %xmm2
193 pxor 48(%rsi), %xmm2
194 ptest %xmm2, %xmm0
195 jnc L(64bytesin256)
196
197 movdqu 64(%rdi), %xmm2
198 pxor 64(%rsi), %xmm2
199 ptest %xmm2, %xmm0
200 jnc L(80bytesin256)
201
202 movdqu 80(%rdi), %xmm2
203 pxor 80(%rsi), %xmm2
204 ptest %xmm2, %xmm0
205 jnc L(96bytesin256)
206
207 movdqu 96(%rdi), %xmm2
208 pxor 96(%rsi), %xmm2
209 ptest %xmm2, %xmm0
210 jnc L(112bytesin256)
211
212 movdqu 112(%rdi), %xmm2
213 pxor 112(%rsi), %xmm2
214 ptest %xmm2, %xmm0
215 jnc L(128bytesin256)
216
217 add $128, %rsi
218 add $128, %rdi
219
220 cmp $64, %rdx
221 jae L(less128bytes)
222
223 cmp $32, %rdx
224 jb L(less32bytesin128)
225
226 movdqu (%rdi), %xmm2
227 pxor (%rsi), %xmm2
228 ptest %xmm2, %xmm0
229 jnc L(16bytesin256)
230
231 movdqu 16(%rdi), %xmm2
232 pxor 16(%rsi), %xmm2
233 ptest %xmm2, %xmm0
234 jnc L(32bytesin256)
235 sub $32, %rdx
236 add $32, %rdi
237 add $32, %rsi
238L(less32bytesin128):
239 add %rdx, %rsi
240 add %rdx, %rdi
241 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
242
243L(less512bytes):
244 sub $256, %rdx
245 movdqu (%rdi), %xmm2
246 pxor (%rsi), %xmm2
247 ptest %xmm2, %xmm0
248 jnc L(16bytesin256)
249
250 movdqu 16(%rdi), %xmm2
251 pxor 16(%rsi), %xmm2
252 ptest %xmm2, %xmm0
253 jnc L(32bytesin256)
254
255 movdqu 32(%rdi), %xmm2
256 pxor 32(%rsi), %xmm2
257 ptest %xmm2, %xmm0
258 jnc L(48bytesin256)
259
260 movdqu 48(%rdi), %xmm2
261 pxor 48(%rsi), %xmm2
262 ptest %xmm2, %xmm0
263 jnc L(64bytesin256)
264
265 movdqu 64(%rdi), %xmm2
266 pxor 64(%rsi), %xmm2
267 ptest %xmm2, %xmm0
268 jnc L(80bytesin256)
269
270 movdqu 80(%rdi), %xmm2
271 pxor 80(%rsi), %xmm2
272 ptest %xmm2, %xmm0
273 jnc L(96bytesin256)
274
275 movdqu 96(%rdi), %xmm2
276 pxor 96(%rsi), %xmm2
277 ptest %xmm2, %xmm0
278 jnc L(112bytesin256)
279
280 movdqu 112(%rdi), %xmm2
281 pxor 112(%rsi), %xmm2
282 ptest %xmm2, %xmm0
283 jnc L(128bytesin256)
284
285 movdqu 128(%rdi), %xmm2
286 pxor 128(%rsi), %xmm2
287 ptest %xmm2, %xmm0
288 jnc L(144bytesin256)
289
290 movdqu 144(%rdi), %xmm2
291 pxor 144(%rsi), %xmm2
292 ptest %xmm2, %xmm0
293 jnc L(160bytesin256)
294
295 movdqu 160(%rdi), %xmm2
296 pxor 160(%rsi), %xmm2
297 ptest %xmm2, %xmm0
298 jnc L(176bytesin256)
299
300 movdqu 176(%rdi), %xmm2
301 pxor 176(%rsi), %xmm2
302 ptest %xmm2, %xmm0
303 jnc L(192bytesin256)
304
305 movdqu 192(%rdi), %xmm2
306 pxor 192(%rsi), %xmm2
307 ptest %xmm2, %xmm0
308 jnc L(208bytesin256)
309
310 movdqu 208(%rdi), %xmm2
311 pxor 208(%rsi), %xmm2
312 ptest %xmm2, %xmm0
313 jnc L(224bytesin256)
314
315 movdqu 224(%rdi), %xmm2
316 pxor 224(%rsi), %xmm2
317 ptest %xmm2, %xmm0
318 jnc L(240bytesin256)
319
320 movdqu 240(%rdi), %xmm2
321 pxor 240(%rsi), %xmm2
322 ptest %xmm2, %xmm0
323 jnc L(256bytesin256)
324
325 add $256, %rsi
326 add $256, %rdi
327
328 cmp $128, %rdx
329 jae L(less256bytes)
330
331 cmp $64, %rdx
332 jae L(less128bytes)
333
334 cmp $32, %rdx
335 jb L(less32bytesin256)
336
337 movdqu (%rdi), %xmm2
338 pxor (%rsi), %xmm2
339 ptest %xmm2, %xmm0
340 jnc L(16bytesin256)
341
342 movdqu 16(%rdi), %xmm2
343 pxor 16(%rsi), %xmm2
344 ptest %xmm2, %xmm0
345 jnc L(32bytesin256)
346 sub $32, %rdx
347 add $32, %rdi
348 add $32, %rsi
349L(less32bytesin256):
350 add %rdx, %rsi
351 add %rdx, %rdi
352 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
353
354 ALIGN (4)
355L(512bytesormore):
356#ifdef DATA_CACHE_SIZE_HALF
357 mov $DATA_CACHE_SIZE_HALF, %r8
358#else
359 mov __x86_64_data_cache_size_half(%rip), %r8
360#endif
361 mov %r8, %r9
362 shr $1, %r8
363 add %r9, %r8
364 cmp %r8, %rdx
365 ja L(L2_L3_cache_unaglined)
366 sub $64, %rdx
367 ALIGN (4)
368L(64bytesormore_loop):
369 movdqu (%rdi), %xmm2
370 pxor (%rsi), %xmm2
371 movdqa %xmm2, %xmm1
372
373 movdqu 16(%rdi), %xmm3
374 pxor 16(%rsi), %xmm3
375 por %xmm3, %xmm1
376
377 movdqu 32(%rdi), %xmm4
378 pxor 32(%rsi), %xmm4
379 por %xmm4, %xmm1
380
381 movdqu 48(%rdi), %xmm5
382 pxor 48(%rsi), %xmm5
383 por %xmm5, %xmm1
384
385 ptest %xmm1, %xmm0
386 jnc L(64bytesormore_loop_end)
387 add $64, %rsi
388 add $64, %rdi
389 sub $64, %rdx
390 jae L(64bytesormore_loop)
391
392 add $64, %rdx
393 add %rdx, %rsi
394 add %rdx, %rdi
395 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
396
397L(L2_L3_cache_unaglined):
398 sub $64, %rdx
399 ALIGN (4)
400L(L2_L3_unaligned_128bytes_loop):
401 prefetchnta 0x1c0(%rdi)
402 prefetchnta 0x1c0(%rsi)
403 movdqu (%rdi), %xmm2
404 pxor (%rsi), %xmm2
405 movdqa %xmm2, %xmm1
406
407 movdqu 16(%rdi), %xmm3
408 pxor 16(%rsi), %xmm3
409 por %xmm3, %xmm1
410
411 movdqu 32(%rdi), %xmm4
412 pxor 32(%rsi), %xmm4
413 por %xmm4, %xmm1
414
415 movdqu 48(%rdi), %xmm5
416 pxor 48(%rsi), %xmm5
417 por %xmm5, %xmm1
418
419 ptest %xmm1, %xmm0
420 jnc L(64bytesormore_loop_end)
421 add $64, %rsi
422 add $64, %rdi
423 sub $64, %rdx
424 jae L(L2_L3_unaligned_128bytes_loop)
425
426 add $64, %rdx
427 add %rdx, %rsi
428 add %rdx, %rdi
429 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
430
431/*
432 * This case is for machines which are sensitive for unaligned instructions.
433 */
434 ALIGN (4)
435L(2aligned):
436 cmp $128, %rdx
437 ja L(128bytesormorein2aligned)
438L(less128bytesin2aligned):
439 sub $64, %rdx
440
441 movdqa (%rdi), %xmm2
442 pxor (%rsi), %xmm2
443 ptest %xmm2, %xmm0
444 jnc L(16bytesin256)
445
446 movdqa 16(%rdi), %xmm2
447 pxor 16(%rsi), %xmm2
448 ptest %xmm2, %xmm0
449 jnc L(32bytesin256)
450
451 movdqa 32(%rdi), %xmm2
452 pxor 32(%rsi), %xmm2
453 ptest %xmm2, %xmm0
454 jnc L(48bytesin256)
455
456 movdqa 48(%rdi), %xmm2
457 pxor 48(%rsi), %xmm2
458 ptest %xmm2, %xmm0
459 jnc L(64bytesin256)
460 cmp $32, %rdx
461 jb L(less32bytesin64in2alinged)
462
463 movdqa 64(%rdi), %xmm2
464 pxor 64(%rsi), %xmm2
465 ptest %xmm2, %xmm0
466 jnc L(80bytesin256)
467
468 movdqa 80(%rdi), %xmm2
469 pxor 80(%rsi), %xmm2
470 ptest %xmm2, %xmm0
471 jnc L(96bytesin256)
472 sub $32, %rdx
473 add $32, %rdi
474 add $32, %rsi
475L(less32bytesin64in2alinged):
476 add $64, %rdi
477 add $64, %rsi
478 add %rdx, %rsi
479 add %rdx, %rdi
480 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
481
482 ALIGN (4)
483L(128bytesormorein2aligned):
484 cmp $512, %rdx
485 ja L(512bytesormorein2aligned)
486 cmp $256, %rdx
487 ja L(256bytesormorein2aligned)
488L(less256bytesin2alinged):
489 sub $128, %rdx
490
491 movdqa (%rdi), %xmm2
492 pxor (%rsi), %xmm2
493 ptest %xmm2, %xmm0
494 jnc L(16bytesin256)
495
496 movdqa 16(%rdi), %xmm2
497 pxor 16(%rsi), %xmm2
498 ptest %xmm2, %xmm0
499 jnc L(32bytesin256)
500
501 movdqa 32(%rdi), %xmm2
502 pxor 32(%rsi), %xmm2
503 ptest %xmm2, %xmm0
504 jnc L(48bytesin256)
505
506 movdqa 48(%rdi), %xmm2
507 pxor 48(%rsi), %xmm2
508 ptest %xmm2, %xmm0
509 jnc L(64bytesin256)
510
511 movdqa 64(%rdi), %xmm2
512 pxor 64(%rsi), %xmm2
513 ptest %xmm2, %xmm0
514 jnc L(80bytesin256)
515
516 movdqa 80(%rdi), %xmm2
517 pxor 80(%rsi), %xmm2
518 ptest %xmm2, %xmm0
519 jnc L(96bytesin256)
520
521 movdqa 96(%rdi), %xmm2
522 pxor 96(%rsi), %xmm2
523 ptest %xmm2, %xmm0
524 jnc L(112bytesin256)
525
526 movdqa 112(%rdi), %xmm2
527 pxor 112(%rsi), %xmm2
528 ptest %xmm2, %xmm0
529 jnc L(128bytesin256)
530
531 add $128, %rsi
532 add $128, %rdi
533
534 cmp $64, %rdx
535 jae L(less128bytesin2aligned)
536
537 cmp $32, %rdx
538 jb L(less32bytesin128in2aligned)
539
540 movdqu (%rdi), %xmm2
541 pxor (%rsi), %xmm2
542 ptest %xmm2, %xmm0
543 jnc L(16bytesin256)
544
545 movdqu 16(%rdi), %xmm2
546 pxor 16(%rsi), %xmm2
547 ptest %xmm2, %xmm0
548 jnc L(32bytesin256)
549 sub $32, %rdx
550 add $32, %rdi
551 add $32, %rsi
552L(less32bytesin128in2aligned):
553 add %rdx, %rsi
554 add %rdx, %rdi
555 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
556
557 ALIGN (4)
558L(256bytesormorein2aligned):
559
560 sub $256, %rdx
561 movdqa (%rdi), %xmm2
562 pxor (%rsi), %xmm2
563 ptest %xmm2, %xmm0
564 jnc L(16bytesin256)
565
566 movdqa 16(%rdi), %xmm2
567 pxor 16(%rsi), %xmm2
568 ptest %xmm2, %xmm0
569 jnc L(32bytesin256)
570
571 movdqa 32(%rdi), %xmm2
572 pxor 32(%rsi), %xmm2
573 ptest %xmm2, %xmm0
574 jnc L(48bytesin256)
575
576 movdqa 48(%rdi), %xmm2
577 pxor 48(%rsi), %xmm2
578 ptest %xmm2, %xmm0
579 jnc L(64bytesin256)
580
581 movdqa 64(%rdi), %xmm2
582 pxor 64(%rsi), %xmm2
583 ptest %xmm2, %xmm0
584 jnc L(80bytesin256)
585
586 movdqa 80(%rdi), %xmm2
587 pxor 80(%rsi), %xmm2
588 ptest %xmm2, %xmm0
589 jnc L(96bytesin256)
590
591 movdqa 96(%rdi), %xmm2
592 pxor 96(%rsi), %xmm2
593 ptest %xmm2, %xmm0
594 jnc L(112bytesin256)
595
596 movdqa 112(%rdi), %xmm2
597 pxor 112(%rsi), %xmm2
598 ptest %xmm2, %xmm0
599 jnc L(128bytesin256)
600
601 movdqa 128(%rdi), %xmm2
602 pxor 128(%rsi), %xmm2
603 ptest %xmm2, %xmm0
604 jnc L(144bytesin256)
605
606 movdqa 144(%rdi), %xmm2
607 pxor 144(%rsi), %xmm2
608 ptest %xmm2, %xmm0
609 jnc L(160bytesin256)
610
611 movdqa 160(%rdi), %xmm2
612 pxor 160(%rsi), %xmm2
613 ptest %xmm2, %xmm0
614 jnc L(176bytesin256)
615
616 movdqa 176(%rdi), %xmm2
617 pxor 176(%rsi), %xmm2
618 ptest %xmm2, %xmm0
619 jnc L(192bytesin256)
620
621 movdqa 192(%rdi), %xmm2
622 pxor 192(%rsi), %xmm2
623 ptest %xmm2, %xmm0
624 jnc L(208bytesin256)
625
626 movdqa 208(%rdi), %xmm2
627 pxor 208(%rsi), %xmm2
628 ptest %xmm2, %xmm0
629 jnc L(224bytesin256)
630
631 movdqa 224(%rdi), %xmm2
632 pxor 224(%rsi), %xmm2
633 ptest %xmm2, %xmm0
634 jnc L(240bytesin256)
635
636 movdqa 240(%rdi), %xmm2
637 pxor 240(%rsi), %xmm2
638 ptest %xmm2, %xmm0
639 jnc L(256bytesin256)
640
641 add $256, %rsi
642 add $256, %rdi
643
644 cmp $128, %rdx
645 jae L(less256bytesin2alinged)
646
647 cmp $64, %rdx
648 jae L(less128bytesin2aligned)
649
650 cmp $32, %rdx
651 jb L(less32bytesin256in2alinged)
652
653 movdqa (%rdi), %xmm2
654 pxor (%rsi), %xmm2
655 ptest %xmm2, %xmm0
656 jnc L(16bytesin256)
657
658 movdqa 16(%rdi), %xmm2
659 pxor 16(%rsi), %xmm2
660 ptest %xmm2, %xmm0
661 jnc L(32bytesin256)
662 sub $32, %rdx
663 add $32, %rdi
664 add $32, %rsi
665L(less32bytesin256in2alinged):
666 add %rdx, %rsi
667 add %rdx, %rdi
668 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
669
670 ALIGN (4)
671L(512bytesormorein2aligned):
672#ifdef DATA_CACHE_SIZE_HALF
673 mov $DATA_CACHE_SIZE_HALF, %r8
674#else
675 mov __x86_64_data_cache_size_half(%rip), %r8
676#endif
677 mov %r8, %r9
678 shr $1, %r8
679 add %r9, %r8
680 cmp %r8, %rdx
681 ja L(L2_L3_cache_aglined)
682
683 sub $64, %rdx
684 ALIGN (4)
685L(64bytesormore_loopin2aligned):
686 movdqa (%rdi), %xmm2
687 pxor (%rsi), %xmm2
688 movdqa %xmm2, %xmm1
689
690 movdqa 16(%rdi), %xmm3
691 pxor 16(%rsi), %xmm3
692 por %xmm3, %xmm1
693
694 movdqa 32(%rdi), %xmm4
695 pxor 32(%rsi), %xmm4
696 por %xmm4, %xmm1
697
698 movdqa 48(%rdi), %xmm5
699 pxor 48(%rsi), %xmm5
700 por %xmm5, %xmm1
701
702 ptest %xmm1, %xmm0
703 jnc L(64bytesormore_loop_end)
704 add $64, %rsi
705 add $64, %rdi
706 sub $64, %rdx
707 jae L(64bytesormore_loopin2aligned)
708
709 add $64, %rdx
710 add %rdx, %rsi
711 add %rdx, %rdi
712 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
713L(L2_L3_cache_aglined):
714 sub $64, %rdx
715 ALIGN (4)
716L(L2_L3_aligned_128bytes_loop):
717 prefetchnta 0x1c0(%rdi)
718 prefetchnta 0x1c0(%rsi)
719 movdqa (%rdi), %xmm2
720 pxor (%rsi), %xmm2
721 movdqa %xmm2, %xmm1
722
723 movdqa 16(%rdi), %xmm3
724 pxor 16(%rsi), %xmm3
725 por %xmm3, %xmm1
726
727 movdqa 32(%rdi), %xmm4
728 pxor 32(%rsi), %xmm4
729 por %xmm4, %xmm1
730
731 movdqa 48(%rdi), %xmm5
732 pxor 48(%rsi), %xmm5
733 por %xmm5, %xmm1
734
735 ptest %xmm1, %xmm0
736 jnc L(64bytesormore_loop_end)
737 add $64, %rsi
738 add $64, %rdi
739 sub $64, %rdx
740 jae L(L2_L3_aligned_128bytes_loop)
741
742 add $64, %rdx
743 add %rdx, %rsi
744 add %rdx, %rdi
745 BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
746
747
748 ALIGN (4)
749L(64bytesormore_loop_end):
750 add $16, %rdi
751 add $16, %rsi
752 ptest %xmm2, %xmm0
753 jnc L(16bytes)
754
755 add $16, %rdi
756 add $16, %rsi
757 ptest %xmm3, %xmm0
758 jnc L(16bytes)
759
760 add $16, %rdi
761 add $16, %rsi
762 ptest %xmm4, %xmm0
763 jnc L(16bytes)
764
765 add $16, %rdi
766 add $16, %rsi
767 jmp L(16bytes)
768
769L(256bytesin256):
770 add $256, %rdi
771 add $256, %rsi
772 jmp L(16bytes)
773L(240bytesin256):
774 add $240, %rdi
775 add $240, %rsi
776 jmp L(16bytes)
777L(224bytesin256):
778 add $224, %rdi
779 add $224, %rsi
780 jmp L(16bytes)
781L(208bytesin256):
782 add $208, %rdi
783 add $208, %rsi
784 jmp L(16bytes)
785L(192bytesin256):
786 add $192, %rdi
787 add $192, %rsi
788 jmp L(16bytes)
789L(176bytesin256):
790 add $176, %rdi
791 add $176, %rsi
792 jmp L(16bytes)
793L(160bytesin256):
794 add $160, %rdi
795 add $160, %rsi
796 jmp L(16bytes)
797L(144bytesin256):
798 add $144, %rdi
799 add $144, %rsi
800 jmp L(16bytes)
801L(128bytesin256):
802 add $128, %rdi
803 add $128, %rsi
804 jmp L(16bytes)
805L(112bytesin256):
806 add $112, %rdi
807 add $112, %rsi
808 jmp L(16bytes)
809L(96bytesin256):
810 add $96, %rdi
811 add $96, %rsi
812 jmp L(16bytes)
813L(80bytesin256):
814 add $80, %rdi
815 add $80, %rsi
816 jmp L(16bytes)
817L(64bytesin256):
818 add $64, %rdi
819 add $64, %rsi
820 jmp L(16bytes)
821L(48bytesin256):
822 add $16, %rdi
823 add $16, %rsi
824L(32bytesin256):
825 add $16, %rdi
826 add $16, %rsi
827L(16bytesin256):
828 add $16, %rdi
829 add $16, %rsi
830L(16bytes):
831 mov -16(%rdi), %rax
832 mov -16(%rsi), %rcx
833 cmp %rax, %rcx
834 jne L(diffin8bytes)
835L(8bytes):
836 mov -8(%rdi), %rax
837 mov -8(%rsi), %rcx
838 cmp %rax, %rcx
839 jne L(diffin8bytes)
840 xor %eax, %eax
841 ret
842
843 ALIGN (4)
844L(12bytes):
845 mov -12(%rdi), %rax
846 mov -12(%rsi), %rcx
847 cmp %rax, %rcx
848 jne L(diffin8bytes)
849L(4bytes):
850 mov -4(%rsi), %ecx
851 mov -4(%rdi), %eax
852 cmp %eax, %ecx
853 jne L(diffin4bytes)
854L(0bytes):
855 xor %eax, %eax
856 ret
857
858#ifndef USE_AS_WMEMCMP
859/* unreal case for wmemcmp */
860 ALIGN (4)
861L(65bytes):
862 movdqu -65(%rdi), %xmm1
863 movdqu -65(%rsi), %xmm2
864 mov $-65, %dl
865 pxor %xmm1, %xmm2
866 ptest %xmm2, %xmm0
867 jnc L(less16bytes)
868L(49bytes):
869 movdqu -49(%rdi), %xmm1
870 movdqu -49(%rsi), %xmm2
871 mov $-49, %dl
872 pxor %xmm1, %xmm2
873 ptest %xmm2, %xmm0
874 jnc L(less16bytes)
875L(33bytes):
876 movdqu -33(%rdi), %xmm1
877 movdqu -33(%rsi), %xmm2
878 mov $-33, %dl
879 pxor %xmm1, %xmm2
880 ptest %xmm2, %xmm0
881 jnc L(less16bytes)
882L(17bytes):
883 mov -17(%rdi), %rax
884 mov -17(%rsi), %rcx
885 cmp %rax, %rcx
886 jne L(diffin8bytes)
887L(9bytes):
888 mov -9(%rdi), %rax
889 mov -9(%rsi), %rcx
890 cmp %rax, %rcx
891 jne L(diffin8bytes)
892 movzbl -1(%rdi), %eax
893 movzbl -1(%rsi), %edx
894 sub %edx, %eax
895 ret
896
897 ALIGN (4)
898L(13bytes):
899 mov -13(%rdi), %rax
900 mov -13(%rsi), %rcx
901 cmp %rax, %rcx
902 jne L(diffin8bytes)
903 mov -8(%rdi), %rax
904 mov -8(%rsi), %rcx
905 cmp %rax, %rcx
906 jne L(diffin8bytes)
907 xor %eax, %eax
908 ret
909
910 ALIGN (4)
911L(5bytes):
912 mov -5(%rdi), %eax
913 mov -5(%rsi), %ecx
914 cmp %eax, %ecx
915 jne L(diffin4bytes)
916 movzbl -1(%rdi), %eax
917 movzbl -1(%rsi), %edx
918 sub %edx, %eax
919 ret
920
921 ALIGN (4)
922L(66bytes):
923 movdqu -66(%rdi), %xmm1
924 movdqu -66(%rsi), %xmm2
925 mov $-66, %dl
926 pxor %xmm1, %xmm2
927 ptest %xmm2, %xmm0
928 jnc L(less16bytes)
929L(50bytes):
930 movdqu -50(%rdi), %xmm1
931 movdqu -50(%rsi), %xmm2
932 mov $-50, %dl
933 pxor %xmm1, %xmm2
934 ptest %xmm2, %xmm0
935 jnc L(less16bytes)
936L(34bytes):
937 movdqu -34(%rdi), %xmm1
938 movdqu -34(%rsi), %xmm2
939 mov $-34, %dl
940 pxor %xmm1, %xmm2
941 ptest %xmm2, %xmm0
942 jnc L(less16bytes)
943L(18bytes):
944 mov -18(%rdi), %rax
945 mov -18(%rsi), %rcx
946 cmp %rax, %rcx
947 jne L(diffin8bytes)
948L(10bytes):
949 mov -10(%rdi), %rax
950 mov -10(%rsi), %rcx
951 cmp %rax, %rcx
952 jne L(diffin8bytes)
953 movzwl -2(%rdi), %eax
954 movzwl -2(%rsi), %ecx
955 cmp %cl, %al
956 jne L(end)
957 and $0xffff, %eax
958 and $0xffff, %ecx
959 sub %ecx, %eax
960 ret
961
962 ALIGN (4)
963L(14bytes):
964 mov -14(%rdi), %rax
965 mov -14(%rsi), %rcx
966 cmp %rax, %rcx
967 jne L(diffin8bytes)
968 mov -8(%rdi), %rax
969 mov -8(%rsi), %rcx
970 cmp %rax, %rcx
971 jne L(diffin8bytes)
972 xor %eax, %eax
973 ret
974
975 ALIGN (4)
976L(6bytes):
977 mov -6(%rdi), %eax
978 mov -6(%rsi), %ecx
979 cmp %eax, %ecx
980 jne L(diffin4bytes)
981L(2bytes):
982 movzwl -2(%rsi), %ecx
983 movzwl -2(%rdi), %eax
984 cmp %cl, %al
985 jne L(end)
986 and $0xffff, %eax
987 and $0xffff, %ecx
988 sub %ecx, %eax
989 ret
990
991 ALIGN (4)
992L(67bytes):
993 movdqu -67(%rdi), %xmm2
994 movdqu -67(%rsi), %xmm1
995 mov $-67, %dl
996 pxor %xmm1, %xmm2
997 ptest %xmm2, %xmm0
998 jnc L(less16bytes)
999L(51bytes):
1000 movdqu -51(%rdi), %xmm2
1001 movdqu -51(%rsi), %xmm1
1002 mov $-51, %dl
1003 pxor %xmm1, %xmm2
1004 ptest %xmm2, %xmm0
1005 jnc L(less16bytes)
1006L(35bytes):
1007 movdqu -35(%rsi), %xmm1
1008 movdqu -35(%rdi), %xmm2
1009 mov $-35, %dl
1010 pxor %xmm1, %xmm2
1011 ptest %xmm2, %xmm0
1012 jnc L(less16bytes)
1013L(19bytes):
1014 mov -19(%rdi), %rax
1015 mov -19(%rsi), %rcx
1016 cmp %rax, %rcx
1017 jne L(diffin8bytes)
1018L(11bytes):
1019 mov -11(%rdi), %rax
1020 mov -11(%rsi), %rcx
1021 cmp %rax, %rcx
1022 jne L(diffin8bytes)
1023 mov -4(%rdi), %eax
1024 mov -4(%rsi), %ecx
1025 cmp %eax, %ecx
1026 jne L(diffin4bytes)
1027 xor %eax, %eax
1028 ret
1029
1030 ALIGN (4)
1031L(15bytes):
1032 mov -15(%rdi), %rax
1033 mov -15(%rsi), %rcx
1034 cmp %rax, %rcx
1035 jne L(diffin8bytes)
1036 mov -8(%rdi), %rax
1037 mov -8(%rsi), %rcx
1038 cmp %rax, %rcx
1039 jne L(diffin8bytes)
1040 xor %eax, %eax
1041 ret
1042
1043 ALIGN (4)
1044L(7bytes):
1045 mov -7(%rdi), %eax
1046 mov -7(%rsi), %ecx
1047 cmp %eax, %ecx
1048 jne L(diffin4bytes)
1049 mov -4(%rdi), %eax
1050 mov -4(%rsi), %ecx
1051 cmp %eax, %ecx
1052 jne L(diffin4bytes)
1053 xor %eax, %eax
1054 ret
1055
1056 ALIGN (4)
1057L(3bytes):
1058 movzwl -3(%rdi), %eax
1059 movzwl -3(%rsi), %ecx
1060 cmp %eax, %ecx
1061 jne L(diffin2bytes)
1062L(1bytes):
1063 movzbl -1(%rdi), %eax
1064 movzbl -1(%rsi), %ecx
1065 sub %ecx, %eax
1066 ret
1067#endif
1068
1069 ALIGN (4)
1070L(68bytes):
1071 movdqu -68(%rdi), %xmm2
1072 movdqu -68(%rsi), %xmm1
1073 mov $-68, %dl
1074 pxor %xmm1, %xmm2
1075 ptest %xmm2, %xmm0
1076 jnc L(less16bytes)
1077L(52bytes):
1078 movdqu -52(%rdi), %xmm2
1079 movdqu -52(%rsi), %xmm1
1080 mov $-52, %dl
1081 pxor %xmm1, %xmm2
1082 ptest %xmm2, %xmm0
1083 jnc L(less16bytes)
1084L(36bytes):
1085 movdqu -36(%rdi), %xmm2
1086 movdqu -36(%rsi), %xmm1
1087 mov $-36, %dl
1088 pxor %xmm1, %xmm2
1089 ptest %xmm2, %xmm0
1090 jnc L(less16bytes)
1091L(20bytes):
1092 movdqu -20(%rdi), %xmm2
1093 movdqu -20(%rsi), %xmm1
1094 mov $-20, %dl
1095 pxor %xmm1, %xmm2
1096 ptest %xmm2, %xmm0
1097 jnc L(less16bytes)
1098 mov -4(%rdi), %eax
1099 mov -4(%rsi), %ecx
1100 cmp %eax, %ecx
1101 jne L(diffin4bytes)
1102 xor %eax, %eax
1103 ret
1104
1105#ifndef USE_AS_WMEMCMP
1106/* unreal cases for wmemcmp */
1107 ALIGN (4)
1108L(69bytes):
1109 movdqu -69(%rsi), %xmm1
1110 movdqu -69(%rdi), %xmm2
1111 mov $-69, %dl
1112 pxor %xmm1, %xmm2
1113 ptest %xmm2, %xmm0
1114 jnc L(less16bytes)
1115L(53bytes):
1116 movdqu -53(%rsi), %xmm1
1117 movdqu -53(%rdi), %xmm2
1118 mov $-53, %dl
1119 pxor %xmm1, %xmm2
1120 ptest %xmm2, %xmm0
1121 jnc L(less16bytes)
1122L(37bytes):
1123 movdqu -37(%rsi), %xmm1
1124 movdqu -37(%rdi), %xmm2
1125 mov $-37, %dl
1126 pxor %xmm1, %xmm2
1127 ptest %xmm2, %xmm0
1128 jnc L(less16bytes)
1129L(21bytes):
1130 movdqu -21(%rsi), %xmm1
1131 movdqu -21(%rdi), %xmm2
1132 mov $-21, %dl
1133 pxor %xmm1, %xmm2
1134 ptest %xmm2, %xmm0
1135 jnc L(less16bytes)
1136 mov -8(%rdi), %rax
1137 mov -8(%rsi), %rcx
1138 cmp %rax, %rcx
1139 jne L(diffin8bytes)
1140 xor %eax, %eax
1141 ret
1142
1143 ALIGN (4)
1144L(70bytes):
1145 movdqu -70(%rsi), %xmm1
1146 movdqu -70(%rdi), %xmm2
1147 mov $-70, %dl
1148 pxor %xmm1, %xmm2
1149 ptest %xmm2, %xmm0
1150 jnc L(less16bytes)
1151L(54bytes):
1152 movdqu -54(%rsi), %xmm1
1153 movdqu -54(%rdi), %xmm2
1154 mov $-54, %dl
1155 pxor %xmm1, %xmm2
1156 ptest %xmm2, %xmm0
1157 jnc L(less16bytes)
1158L(38bytes):
1159 movdqu -38(%rsi), %xmm1
1160 movdqu -38(%rdi), %xmm2
1161 mov $-38, %dl
1162 pxor %xmm1, %xmm2
1163 ptest %xmm2, %xmm0
1164 jnc L(less16bytes)
1165L(22bytes):
1166 movdqu -22(%rsi), %xmm1
1167 movdqu -22(%rdi), %xmm2
1168 mov $-22, %dl
1169 pxor %xmm1, %xmm2
1170 ptest %xmm2, %xmm0
1171 jnc L(less16bytes)
1172 mov -8(%rdi), %rax
1173 mov -8(%rsi), %rcx
1174 cmp %rax, %rcx
1175 jne L(diffin8bytes)
1176 xor %eax, %eax
1177 ret
1178
1179 ALIGN (4)
1180L(71bytes):
1181 movdqu -71(%rsi), %xmm1
1182 movdqu -71(%rdi), %xmm2
1183 mov $-71, %dl
1184 pxor %xmm1, %xmm2
1185 ptest %xmm2, %xmm0
1186 jnc L(less16bytes)
1187L(55bytes):
1188 movdqu -55(%rdi), %xmm2
1189 movdqu -55(%rsi), %xmm1
1190 mov $-55, %dl
1191 pxor %xmm1, %xmm2
1192 ptest %xmm2, %xmm0
1193 jnc L(less16bytes)
1194L(39bytes):
1195 movdqu -39(%rdi), %xmm2
1196 movdqu -39(%rsi), %xmm1
1197 mov $-39, %dl
1198 pxor %xmm1, %xmm2
1199 ptest %xmm2, %xmm0
1200 jnc L(less16bytes)
1201L(23bytes):
1202 movdqu -23(%rdi), %xmm2
1203 movdqu -23(%rsi), %xmm1
1204 mov $-23, %dl
1205 pxor %xmm1, %xmm2
1206 ptest %xmm2, %xmm0
1207 jnc L(less16bytes)
1208 mov -8(%rdi), %rax
1209 mov -8(%rsi), %rcx
1210 cmp %rax, %rcx
1211 jne L(diffin8bytes)
1212 xor %eax, %eax
1213 ret
1214#endif
1215
1216 ALIGN (4)
1217L(72bytes):
1218 movdqu -72(%rsi), %xmm1
1219 movdqu -72(%rdi), %xmm2
1220 mov $-72, %dl
1221 pxor %xmm1, %xmm2
1222 ptest %xmm2, %xmm0
1223 jnc L(less16bytes)
1224L(56bytes):
1225 movdqu -56(%rdi), %xmm2
1226 movdqu -56(%rsi), %xmm1
1227 mov $-56, %dl
1228 pxor %xmm1, %xmm2
1229 ptest %xmm2, %xmm0
1230 jnc L(less16bytes)
1231L(40bytes):
1232 movdqu -40(%rdi), %xmm2
1233 movdqu -40(%rsi), %xmm1
1234 mov $-40, %dl
1235 pxor %xmm1, %xmm2
1236 ptest %xmm2, %xmm0
1237 jnc L(less16bytes)
1238L(24bytes):
1239 movdqu -24(%rdi), %xmm2
1240 movdqu -24(%rsi), %xmm1
1241 mov $-24, %dl
1242 pxor %xmm1, %xmm2
1243 ptest %xmm2, %xmm0
1244 jnc L(less16bytes)
1245 mov -8(%rdi), %rax
1246 mov -8(%rsi), %rcx
1247 cmp %rax, %rcx
1248 jne L(diffin8bytes)
1249 xor %eax, %eax
1250 ret
1251
1252#ifndef USE_AS_WMEMCMP
1253/* unreal cases for wmemcmp */
1254 ALIGN (4)
1255L(73bytes):
1256 movdqu -73(%rsi), %xmm1
1257 movdqu -73(%rdi), %xmm2
1258 mov $-73, %dl
1259 pxor %xmm1, %xmm2
1260 ptest %xmm2, %xmm0
1261 jnc L(less16bytes)
1262L(57bytes):
1263 movdqu -57(%rdi), %xmm2
1264 movdqu -57(%rsi), %xmm1
1265 mov $-57, %dl
1266 pxor %xmm1, %xmm2
1267 ptest %xmm2, %xmm0
1268 jnc L(less16bytes)
1269L(41bytes):
1270 movdqu -41(%rdi), %xmm2
1271 movdqu -41(%rsi), %xmm1
1272 mov $-41, %dl
1273 pxor %xmm1, %xmm2
1274 ptest %xmm2, %xmm0
1275 jnc L(less16bytes)
1276L(25bytes):
1277 movdqu -25(%rdi), %xmm2
1278 movdqu -25(%rsi), %xmm1
1279 mov $-25, %dl
1280 pxor %xmm1, %xmm2
1281 ptest %xmm2, %xmm0
1282 jnc L(less16bytes)
1283 mov -9(%rdi), %rax
1284 mov -9(%rsi), %rcx
1285 cmp %rax, %rcx
1286 jne L(diffin8bytes)
1287 movzbl -1(%rdi), %eax
1288 movzbl -1(%rsi), %ecx
1289 sub %ecx, %eax
1290 ret
1291
1292 ALIGN (4)
1293L(74bytes):
1294 movdqu -74(%rsi), %xmm1
1295 movdqu -74(%rdi), %xmm2
1296 mov $-74, %dl
1297 pxor %xmm1, %xmm2
1298 ptest %xmm2, %xmm0
1299 jnc L(less16bytes)
1300L(58bytes):
1301 movdqu -58(%rdi), %xmm2
1302 movdqu -58(%rsi), %xmm1
1303 mov $-58, %dl
1304 pxor %xmm1, %xmm2
1305 ptest %xmm2, %xmm0
1306 jnc L(less16bytes)
1307L(42bytes):
1308 movdqu -42(%rdi), %xmm2
1309 movdqu -42(%rsi), %xmm1
1310 mov $-42, %dl
1311 pxor %xmm1, %xmm2
1312 ptest %xmm2, %xmm0
1313 jnc L(less16bytes)
1314L(26bytes):
1315 movdqu -26(%rdi), %xmm2
1316 movdqu -26(%rsi), %xmm1
1317 mov $-26, %dl
1318 pxor %xmm1, %xmm2
1319 ptest %xmm2, %xmm0
1320 jnc L(less16bytes)
1321 mov -10(%rdi), %rax
1322 mov -10(%rsi), %rcx
1323 cmp %rax, %rcx
1324 jne L(diffin8bytes)
1325 movzwl -2(%rdi), %eax
1326 movzwl -2(%rsi), %ecx
1327 jmp L(diffin2bytes)
1328
1329 ALIGN (4)
1330L(75bytes):
1331 movdqu -75(%rsi), %xmm1
1332 movdqu -75(%rdi), %xmm2
1333 mov $-75, %dl
1334 pxor %xmm1, %xmm2
1335 ptest %xmm2, %xmm0
1336 jnc L(less16bytes)
1337L(59bytes):
1338 movdqu -59(%rdi), %xmm2
1339 movdqu -59(%rsi), %xmm1
1340 mov $-59, %dl
1341 pxor %xmm1, %xmm2
1342 ptest %xmm2, %xmm0
1343 jnc L(less16bytes)
1344L(43bytes):
1345 movdqu -43(%rdi), %xmm2
1346 movdqu -43(%rsi), %xmm1
1347 mov $-43, %dl
1348 pxor %xmm1, %xmm2
1349 ptest %xmm2, %xmm0
1350 jnc L(less16bytes)
1351L(27bytes):
1352 movdqu -27(%rdi), %xmm2
1353 movdqu -27(%rsi), %xmm1
1354 mov $-27, %dl
1355 pxor %xmm1, %xmm2
1356 ptest %xmm2, %xmm0
1357 jnc L(less16bytes)
1358 mov -11(%rdi), %rax
1359 mov -11(%rsi), %rcx
1360 cmp %rax, %rcx
1361 jne L(diffin8bytes)
1362 mov -4(%rdi), %eax
1363 mov -4(%rsi), %ecx
1364 cmp %eax, %ecx
1365 jne L(diffin4bytes)
1366 xor %eax, %eax
1367 ret
1368#endif
1369 ALIGN (4)
1370L(76bytes):
1371 movdqu -76(%rsi), %xmm1
1372 movdqu -76(%rdi), %xmm2
1373 mov $-76, %dl
1374 pxor %xmm1, %xmm2
1375 ptest %xmm2, %xmm0
1376 jnc L(less16bytes)
1377L(60bytes):
1378 movdqu -60(%rdi), %xmm2
1379 movdqu -60(%rsi), %xmm1
1380 mov $-60, %dl
1381 pxor %xmm1, %xmm2
1382 ptest %xmm2, %xmm0
1383 jnc L(less16bytes)
1384L(44bytes):
1385 movdqu -44(%rdi), %xmm2
1386 movdqu -44(%rsi), %xmm1
1387 mov $-44, %dl
1388 pxor %xmm1, %xmm2
1389 ptest %xmm2, %xmm0
1390 jnc L(less16bytes)
1391L(28bytes):
1392 movdqu -28(%rdi), %xmm2
1393 movdqu -28(%rsi), %xmm1
1394 mov $-28, %dl
1395 pxor %xmm1, %xmm2
1396 ptest %xmm2, %xmm0
1397 jnc L(less16bytes)
1398 mov -12(%rdi), %rax
1399 mov -12(%rsi), %rcx
1400 cmp %rax, %rcx
1401 jne L(diffin8bytes)
1402 mov -4(%rdi), %eax
1403 mov -4(%rsi), %ecx
1404 cmp %eax, %ecx
1405 jne L(diffin4bytes)
1406 xor %eax, %eax
1407 ret
1408
1409#ifndef USE_AS_WMEMCMP
1410/* unreal cases for wmemcmp */
1411 ALIGN (4)
1412L(77bytes):
1413 movdqu -77(%rsi), %xmm1
1414 movdqu -77(%rdi), %xmm2
1415 mov $-77, %dl
1416 pxor %xmm1, %xmm2
1417 ptest %xmm2, %xmm0
1418 jnc L(less16bytes)
1419L(61bytes):
1420 movdqu -61(%rdi), %xmm2
1421 movdqu -61(%rsi), %xmm1
1422 mov $-61, %dl
1423 pxor %xmm1, %xmm2
1424 ptest %xmm2, %xmm0
1425 jnc L(less16bytes)
1426L(45bytes):
1427 movdqu -45(%rdi), %xmm2
1428 movdqu -45(%rsi), %xmm1
1429 mov $-45, %dl
1430 pxor %xmm1, %xmm2
1431 ptest %xmm2, %xmm0
1432 jnc L(less16bytes)
1433L(29bytes):
1434 movdqu -29(%rdi), %xmm2
1435 movdqu -29(%rsi), %xmm1
1436 mov $-29, %dl
1437 pxor %xmm1, %xmm2
1438 ptest %xmm2, %xmm0
1439 jnc L(less16bytes)
1440
1441 mov -13(%rdi), %rax
1442 mov -13(%rsi), %rcx
1443 cmp %rax, %rcx
1444 jne L(diffin8bytes)
1445
1446 mov -8(%rdi), %rax
1447 mov -8(%rsi), %rcx
1448 cmp %rax, %rcx
1449 jne L(diffin8bytes)
1450 xor %eax, %eax
1451 ret
1452
1453 ALIGN (4)
1454L(78bytes):
1455 movdqu -78(%rsi), %xmm1
1456 movdqu -78(%rdi), %xmm2
1457 mov $-78, %dl
1458 pxor %xmm1, %xmm2
1459 ptest %xmm2, %xmm0
1460 jnc L(less16bytes)
1461L(62bytes):
1462 movdqu -62(%rdi), %xmm2
1463 movdqu -62(%rsi), %xmm1
1464 mov $-62, %dl
1465 pxor %xmm1, %xmm2
1466 ptest %xmm2, %xmm0
1467 jnc L(less16bytes)
1468L(46bytes):
1469 movdqu -46(%rdi), %xmm2
1470 movdqu -46(%rsi), %xmm1
1471 mov $-46, %dl
1472 pxor %xmm1, %xmm2
1473 ptest %xmm2, %xmm0
1474 jnc L(less16bytes)
1475L(30bytes):
1476 movdqu -30(%rdi), %xmm2
1477 movdqu -30(%rsi), %xmm1
1478 mov $-30, %dl
1479 pxor %xmm1, %xmm2
1480 ptest %xmm2, %xmm0
1481 jnc L(less16bytes)
1482 mov -14(%rdi), %rax
1483 mov -14(%rsi), %rcx
1484 cmp %rax, %rcx
1485 jne L(diffin8bytes)
1486 mov -8(%rdi), %rax
1487 mov -8(%rsi), %rcx
1488 cmp %rax, %rcx
1489 jne L(diffin8bytes)
1490 xor %eax, %eax
1491 ret
1492
1493 ALIGN (4)
1494L(79bytes):
1495 movdqu -79(%rsi), %xmm1
1496 movdqu -79(%rdi), %xmm2
1497 mov $-79, %dl
1498 pxor %xmm1, %xmm2
1499 ptest %xmm2, %xmm0
1500 jnc L(less16bytes)
1501L(63bytes):
1502 movdqu -63(%rdi), %xmm2
1503 movdqu -63(%rsi), %xmm1
1504 mov $-63, %dl
1505 pxor %xmm1, %xmm2
1506 ptest %xmm2, %xmm0
1507 jnc L(less16bytes)
1508L(47bytes):
1509 movdqu -47(%rdi), %xmm2
1510 movdqu -47(%rsi), %xmm1
1511 mov $-47, %dl
1512 pxor %xmm1, %xmm2
1513 ptest %xmm2, %xmm0
1514 jnc L(less16bytes)
1515L(31bytes):
1516 movdqu -31(%rdi), %xmm2
1517 movdqu -31(%rsi), %xmm1
1518 mov $-31, %dl
1519 pxor %xmm1, %xmm2
1520 ptest %xmm2, %xmm0
1521 jnc L(less16bytes)
1522 mov -15(%rdi), %rax
1523 mov -15(%rsi), %rcx
1524 cmp %rax, %rcx
1525 jne L(diffin8bytes)
1526 mov -8(%rdi), %rax
1527 mov -8(%rsi), %rcx
1528 cmp %rax, %rcx
1529 jne L(diffin8bytes)
1530 xor %eax, %eax
1531 ret
1532#endif
1533 ALIGN (4)
1534L(64bytes):
1535 movdqu -64(%rdi), %xmm2
1536 movdqu -64(%rsi), %xmm1
1537 mov $-64, %dl
1538 pxor %xmm1, %xmm2
1539 ptest %xmm2, %xmm0
1540 jnc L(less16bytes)
1541L(48bytes):
1542 movdqu -48(%rdi), %xmm2
1543 movdqu -48(%rsi), %xmm1
1544 mov $-48, %dl
1545 pxor %xmm1, %xmm2
1546 ptest %xmm2, %xmm0
1547 jnc L(less16bytes)
1548L(32bytes):
1549 movdqu -32(%rdi), %xmm2
1550 movdqu -32(%rsi), %xmm1
1551 mov $-32, %dl
1552 pxor %xmm1, %xmm2
1553 ptest %xmm2, %xmm0
1554 jnc L(less16bytes)
1555
1556 mov -16(%rdi), %rax
1557 mov -16(%rsi), %rcx
1558 cmp %rax, %rcx
1559 jne L(diffin8bytes)
1560
1561 mov -8(%rdi), %rax
1562 mov -8(%rsi), %rcx
1563 cmp %rax, %rcx
1564 jne L(diffin8bytes)
1565 xor %eax, %eax
1566 ret
1567
1568/*
1569 * Aligned 8 bytes to avoid 2 branch "taken" in one 16 alinged code block.
1570 */
1571 ALIGN (3)
1572L(less16bytes):
1573 movsbq %dl, %rdx
1574 mov (%rsi, %rdx), %rcx
1575 mov (%rdi, %rdx), %rax
1576 cmp %rax, %rcx
1577 jne L(diffin8bytes)
1578 mov 8(%rsi, %rdx), %rcx
1579 mov 8(%rdi, %rdx), %rax
1580L(diffin8bytes):
1581 cmp %eax, %ecx
1582 jne L(diffin4bytes)
1583 shr $32, %rcx
1584 shr $32, %rax
1585
1586#ifdef USE_AS_WMEMCMP
1587/* for wmemcmp */
1588 cmp %eax, %ecx
1589 jne L(diffin4bytes)
1590 xor %eax, %eax
1591 ret
1592#endif
1593
1594L(diffin4bytes):
1595#ifndef USE_AS_WMEMCMP
1596 cmp %cx, %ax
1597 jne L(diffin2bytes)
1598 shr $16, %ecx
1599 shr $16, %eax
1600L(diffin2bytes):
1601 cmp %cl, %al
1602 jne L(end)
1603 and $0xffff, %eax
1604 and $0xffff, %ecx
1605 sub %ecx, %eax
1606 ret
1607#else
1608
1609/* for wmemcmp */
1610 mov $1, %eax
1611 jl L(nequal_bigger)
1612 neg %eax
1613 ret
1614
1615 ALIGN (4)
1616L(nequal_bigger):
1617 ret
1618
1619L(unreal_case):
1620 xor %eax, %eax
1621 ret
1622#endif
1623
1624 ALIGN (4)
1625L(end):
1626 and $0xff, %eax
1627 and $0xff, %ecx
1628 sub %ecx, %eax
1629 ret
1630
1631END (MEMCMP)
1632
1633 .section .rodata.sse4.1,"a",@progbits
1634 ALIGN (3)
1635#ifndef USE_AS_WMEMCMP
1636L(table_64bytes):
1637 .int JMPTBL (L(0bytes), L(table_64bytes))
1638 .int JMPTBL (L(1bytes), L(table_64bytes))
1639 .int JMPTBL (L(2bytes), L(table_64bytes))
1640 .int JMPTBL (L(3bytes), L(table_64bytes))
1641 .int JMPTBL (L(4bytes), L(table_64bytes))
1642 .int JMPTBL (L(5bytes), L(table_64bytes))
1643 .int JMPTBL (L(6bytes), L(table_64bytes))
1644 .int JMPTBL (L(7bytes), L(table_64bytes))
1645 .int JMPTBL (L(8bytes), L(table_64bytes))
1646 .int JMPTBL (L(9bytes), L(table_64bytes))
1647 .int JMPTBL (L(10bytes), L(table_64bytes))
1648 .int JMPTBL (L(11bytes), L(table_64bytes))
1649 .int JMPTBL (L(12bytes), L(table_64bytes))
1650 .int JMPTBL (L(13bytes), L(table_64bytes))
1651 .int JMPTBL (L(14bytes), L(table_64bytes))
1652 .int JMPTBL (L(15bytes), L(table_64bytes))
1653 .int JMPTBL (L(16bytes), L(table_64bytes))
1654 .int JMPTBL (L(17bytes), L(table_64bytes))
1655 .int JMPTBL (L(18bytes), L(table_64bytes))
1656 .int JMPTBL (L(19bytes), L(table_64bytes))
1657 .int JMPTBL (L(20bytes), L(table_64bytes))
1658 .int JMPTBL (L(21bytes), L(table_64bytes))
1659 .int JMPTBL (L(22bytes), L(table_64bytes))
1660 .int JMPTBL (L(23bytes), L(table_64bytes))
1661 .int JMPTBL (L(24bytes), L(table_64bytes))
1662 .int JMPTBL (L(25bytes), L(table_64bytes))
1663 .int JMPTBL (L(26bytes), L(table_64bytes))
1664 .int JMPTBL (L(27bytes), L(table_64bytes))
1665 .int JMPTBL (L(28bytes), L(table_64bytes))
1666 .int JMPTBL (L(29bytes), L(table_64bytes))
1667 .int JMPTBL (L(30bytes), L(table_64bytes))
1668 .int JMPTBL (L(31bytes), L(table_64bytes))
1669 .int JMPTBL (L(32bytes), L(table_64bytes))
1670 .int JMPTBL (L(33bytes), L(table_64bytes))
1671 .int JMPTBL (L(34bytes), L(table_64bytes))
1672 .int JMPTBL (L(35bytes), L(table_64bytes))
1673 .int JMPTBL (L(36bytes), L(table_64bytes))
1674 .int JMPTBL (L(37bytes), L(table_64bytes))
1675 .int JMPTBL (L(38bytes), L(table_64bytes))
1676 .int JMPTBL (L(39bytes), L(table_64bytes))
1677 .int JMPTBL (L(40bytes), L(table_64bytes))
1678 .int JMPTBL (L(41bytes), L(table_64bytes))
1679 .int JMPTBL (L(42bytes), L(table_64bytes))
1680 .int JMPTBL (L(43bytes), L(table_64bytes))
1681 .int JMPTBL (L(44bytes), L(table_64bytes))
1682 .int JMPTBL (L(45bytes), L(table_64bytes))
1683 .int JMPTBL (L(46bytes), L(table_64bytes))
1684 .int JMPTBL (L(47bytes), L(table_64bytes))
1685 .int JMPTBL (L(48bytes), L(table_64bytes))
1686 .int JMPTBL (L(49bytes), L(table_64bytes))
1687 .int JMPTBL (L(50bytes), L(table_64bytes))
1688 .int JMPTBL (L(51bytes), L(table_64bytes))
1689 .int JMPTBL (L(52bytes), L(table_64bytes))
1690 .int JMPTBL (L(53bytes), L(table_64bytes))
1691 .int JMPTBL (L(54bytes), L(table_64bytes))
1692 .int JMPTBL (L(55bytes), L(table_64bytes))
1693 .int JMPTBL (L(56bytes), L(table_64bytes))
1694 .int JMPTBL (L(57bytes), L(table_64bytes))
1695 .int JMPTBL (L(58bytes), L(table_64bytes))
1696 .int JMPTBL (L(59bytes), L(table_64bytes))
1697 .int JMPTBL (L(60bytes), L(table_64bytes))
1698 .int JMPTBL (L(61bytes), L(table_64bytes))
1699 .int JMPTBL (L(62bytes), L(table_64bytes))
1700 .int JMPTBL (L(63bytes), L(table_64bytes))
1701 .int JMPTBL (L(64bytes), L(table_64bytes))
1702 .int JMPTBL (L(65bytes), L(table_64bytes))
1703 .int JMPTBL (L(66bytes), L(table_64bytes))
1704 .int JMPTBL (L(67bytes), L(table_64bytes))
1705 .int JMPTBL (L(68bytes), L(table_64bytes))
1706 .int JMPTBL (L(69bytes), L(table_64bytes))
1707 .int JMPTBL (L(70bytes), L(table_64bytes))
1708 .int JMPTBL (L(71bytes), L(table_64bytes))
1709 .int JMPTBL (L(72bytes), L(table_64bytes))
1710 .int JMPTBL (L(73bytes), L(table_64bytes))
1711 .int JMPTBL (L(74bytes), L(table_64bytes))
1712 .int JMPTBL (L(75bytes), L(table_64bytes))
1713 .int JMPTBL (L(76bytes), L(table_64bytes))
1714 .int JMPTBL (L(77bytes), L(table_64bytes))
1715 .int JMPTBL (L(78bytes), L(table_64bytes))
1716 .int JMPTBL (L(79bytes), L(table_64bytes))
1717#else
1718L(table_64bytes):
1719 .int JMPTBL (L(0bytes), L(table_64bytes))
1720 .int JMPTBL (L(unreal_case), L(table_64bytes))
1721 .int JMPTBL (L(unreal_case), L(table_64bytes))
1722 .int JMPTBL (L(unreal_case), L(table_64bytes))
1723 .int JMPTBL (L(4bytes), L(table_64bytes))
1724 .int JMPTBL (L(unreal_case), L(table_64bytes))
1725 .int JMPTBL (L(unreal_case), L(table_64bytes))
1726 .int JMPTBL (L(unreal_case), L(table_64bytes))
1727 .int JMPTBL (L(8bytes), L(table_64bytes))
1728 .int JMPTBL (L(unreal_case), L(table_64bytes))
1729 .int JMPTBL (L(unreal_case), L(table_64bytes))
1730 .int JMPTBL (L(unreal_case), L(table_64bytes))
1731 .int JMPTBL (L(12bytes), L(table_64bytes))
1732 .int JMPTBL (L(unreal_case), L(table_64bytes))
1733 .int JMPTBL (L(unreal_case), L(table_64bytes))
1734 .int JMPTBL (L(unreal_case), L(table_64bytes))
1735 .int JMPTBL (L(16bytes), L(table_64bytes))
1736 .int JMPTBL (L(unreal_case), L(table_64bytes))
1737 .int JMPTBL (L(unreal_case), L(table_64bytes))
1738 .int JMPTBL (L(unreal_case), L(table_64bytes))
1739 .int JMPTBL (L(20bytes), L(table_64bytes))
1740 .int JMPTBL (L(unreal_case), L(table_64bytes))
1741 .int JMPTBL (L(unreal_case), L(table_64bytes))
1742 .int JMPTBL (L(unreal_case), L(table_64bytes))
1743 .int JMPTBL (L(24bytes), L(table_64bytes))
1744 .int JMPTBL (L(unreal_case), L(table_64bytes))
1745 .int JMPTBL (L(unreal_case), L(table_64bytes))
1746 .int JMPTBL (L(unreal_case), L(table_64bytes))
1747 .int JMPTBL (L(28bytes), L(table_64bytes))
1748 .int JMPTBL (L(unreal_case), L(table_64bytes))
1749 .int JMPTBL (L(unreal_case), L(table_64bytes))
1750 .int JMPTBL (L(unreal_case), L(table_64bytes))
1751 .int JMPTBL (L(32bytes), L(table_64bytes))
1752 .int JMPTBL (L(unreal_case), L(table_64bytes))
1753 .int JMPTBL (L(unreal_case), L(table_64bytes))
1754 .int JMPTBL (L(unreal_case), L(table_64bytes))
1755 .int JMPTBL (L(36bytes), L(table_64bytes))
1756 .int JMPTBL (L(unreal_case), L(table_64bytes))
1757 .int JMPTBL (L(unreal_case), L(table_64bytes))
1758 .int JMPTBL (L(unreal_case), L(table_64bytes))
1759 .int JMPTBL (L(40bytes), L(table_64bytes))
1760 .int JMPTBL (L(unreal_case), L(table_64bytes))
1761 .int JMPTBL (L(unreal_case), L(table_64bytes))
1762 .int JMPTBL (L(unreal_case), L(table_64bytes))
1763 .int JMPTBL (L(44bytes), L(table_64bytes))
1764 .int JMPTBL (L(unreal_case), L(table_64bytes))
1765 .int JMPTBL (L(unreal_case), L(table_64bytes))
1766 .int JMPTBL (L(unreal_case), L(table_64bytes))
1767 .int JMPTBL (L(48bytes), L(table_64bytes))
1768 .int JMPTBL (L(unreal_case), L(table_64bytes))
1769 .int JMPTBL (L(unreal_case), L(table_64bytes))
1770 .int JMPTBL (L(unreal_case), L(table_64bytes))
1771 .int JMPTBL (L(52bytes), L(table_64bytes))
1772 .int JMPTBL (L(unreal_case), L(table_64bytes))
1773 .int JMPTBL (L(unreal_case), L(table_64bytes))
1774 .int JMPTBL (L(unreal_case), L(table_64bytes))
1775 .int JMPTBL (L(56bytes), L(table_64bytes))
1776 .int JMPTBL (L(unreal_case), L(table_64bytes))
1777 .int JMPTBL (L(unreal_case), L(table_64bytes))
1778 .int JMPTBL (L(unreal_case), L(table_64bytes))
1779 .int JMPTBL (L(60bytes), L(table_64bytes))
1780 .int JMPTBL (L(unreal_case), L(table_64bytes))
1781 .int JMPTBL (L(unreal_case), L(table_64bytes))
1782 .int JMPTBL (L(unreal_case), L(table_64bytes))
1783 .int JMPTBL (L(64bytes), L(table_64bytes))
1784 .int JMPTBL (L(unreal_case), L(table_64bytes))
1785 .int JMPTBL (L(unreal_case), L(table_64bytes))
1786 .int JMPTBL (L(unreal_case), L(table_64bytes))
1787 .int JMPTBL (L(68bytes), L(table_64bytes))
1788 .int JMPTBL (L(unreal_case), L(table_64bytes))
1789 .int JMPTBL (L(unreal_case), L(table_64bytes))
1790 .int JMPTBL (L(unreal_case), L(table_64bytes))
1791 .int JMPTBL (L(72bytes), L(table_64bytes))
1792 .int JMPTBL (L(unreal_case), L(table_64bytes))
1793 .int JMPTBL (L(unreal_case), L(table_64bytes))
1794 .int JMPTBL (L(unreal_case), L(table_64bytes))
1795 .int JMPTBL (L(76bytes), L(table_64bytes))
1796 .int JMPTBL (L(unreal_case), L(table_64bytes))
1797 .int JMPTBL (L(unreal_case), L(table_64bytes))
1798 .int JMPTBL (L(unreal_case), L(table_64bytes))
1799#endif