Optimie x86-64 SSE4 memcmp for unaligned data.
[glibc.git] / sysdeps / x86_64 / multiarch / memcmp-sse4.S
blob25dba864f8cfbc5899165b7fbd7e1f8978592123
1 /* memcmp with SSE4.1
2    Copyright (C) 2010 Free Software Foundation, Inc.
3    Contributed by Intel Corporation.
4    This file is part of the GNU C Library.
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
11    The GNU C Library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
21 #ifndef NOT_IN_libc
23 #include <sysdep.h>
24 #include "asm-syntax.h"
26 #ifndef MEMCMP
27 # define MEMCMP         __memcmp_sse4_1
28 #endif
30 #ifndef ALIGN
31 # define ALIGN(n)       .p2align n
32 #endif
34 #define JMPTBL(I, B)    (I - B)
36 #define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)             \
37   lea           TABLE(%rip), %r11;                              \
38   movslq        (%r11, INDEX, SCALE), %rcx;                     \
39   add           %r11, %rcx;                                     \
40   jmp           *%rcx;                                          \
41   ud2
43         .section .text.sse4.1,"ax",@progbits
44 ENTRY (MEMCMP)
45         pxor    %xmm0, %xmm0
46         cmp     $79, %rdx
47         ja      L(79bytesormore)
48         cmp     $1, %rdx
49         je      L(firstbyte)
50         add     %rdx, %rsi
51         add     %rdx, %rdi
52         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
54         ALIGN (4)
55 L(firstbyte):
56         movzbl  (%rdi), %eax
57         movzbl  (%rsi), %ecx
58         sub     %ecx, %eax
59         ret
61         ALIGN (4)
62 L(79bytesormore):
63         movdqu  (%rsi), %xmm1
64         movdqu  (%rdi), %xmm2
65         pxor    %xmm1, %xmm2
66         ptest   %xmm2, %xmm0
67         jnc     L(16bytesin256)
68         mov     %rsi, %rcx
69         and     $-16, %rsi
70         add     $16, %rsi
71         sub     %rsi, %rcx
73         sub     %rcx, %rdi
74         add     %rcx, %rdx
75         test    $0xf, %rdi
76         jz      L(2aligned)
78         cmp     $128, %rdx
79         ja      L(128bytesormore)
80 L(less128bytes):
81         sub     $64, %rdx
83         movdqu  (%rdi), %xmm2
84         pxor    (%rsi), %xmm2
85         ptest   %xmm2, %xmm0
86         jnc     L(16bytesin256)
88         movdqu  16(%rdi), %xmm2
89         pxor    16(%rsi), %xmm2
90         ptest   %xmm2, %xmm0
91         jnc     L(32bytesin256)
93         movdqu  32(%rdi), %xmm2
94         pxor    32(%rsi), %xmm2
95         ptest   %xmm2, %xmm0
96         jnc     L(48bytesin256)
98         movdqu  48(%rdi), %xmm2
99         pxor    48(%rsi), %xmm2
100         ptest   %xmm2, %xmm0
101         jnc     L(64bytesin256)
102         cmp     $32, %rdx
103         jb      L(less32bytesin64)
105         movdqu  64(%rdi), %xmm2
106         pxor    64(%rsi), %xmm2
107         ptest   %xmm2, %xmm0
108         jnc     L(80bytesin256)
110         movdqu  80(%rdi), %xmm2
111         pxor    80(%rsi), %xmm2
112         ptest   %xmm2, %xmm0
113         jnc     L(96bytesin256)
114         sub     $32, %rdx
115         add     $32, %rdi
116         add     $32, %rsi
117 L(less32bytesin64):
118         add     $64, %rdi
119         add     $64, %rsi
120         add     %rdx, %rsi
121         add     %rdx, %rdi
122         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
124 L(128bytesormore):
125         cmp     $512, %rdx
126         ja      L(512bytesormore)
127         cmp     $256, %rdx
128         ja      L(less512bytes)
129 L(less256bytes):
130         sub     $128, %rdx
132         movdqu  (%rdi), %xmm2
133         pxor    (%rsi), %xmm2
134         ptest   %xmm2, %xmm0
135         jnc     L(16bytesin256)
137         movdqu  16(%rdi), %xmm2
138         pxor    16(%rsi), %xmm2
139         ptest   %xmm2, %xmm0
140         jnc     L(32bytesin256)
142         movdqu  32(%rdi), %xmm2
143         pxor    32(%rsi), %xmm2
144         ptest   %xmm2, %xmm0
145         jnc     L(48bytesin256)
147         movdqu  48(%rdi), %xmm2
148         pxor    48(%rsi), %xmm2
149         ptest   %xmm2, %xmm0
150         jnc     L(64bytesin256)
152         movdqu  64(%rdi), %xmm2
153         pxor    64(%rsi), %xmm2
154         ptest   %xmm2, %xmm0
155         jnc     L(80bytesin256)
157         movdqu  80(%rdi), %xmm2
158         pxor    80(%rsi), %xmm2
159         ptest   %xmm2, %xmm0
160         jnc     L(96bytesin256)
162         movdqu  96(%rdi), %xmm2
163         pxor    96(%rsi), %xmm2
164         ptest   %xmm2, %xmm0
165         jnc     L(112bytesin256)
167         movdqu  112(%rdi), %xmm2
168         pxor    112(%rsi), %xmm2
169         ptest   %xmm2, %xmm0
170         jnc     L(128bytesin256)
172         add     $128, %rsi
173         add     $128, %rdi
175         cmp     $64, %rdx
176         jae     L(less128bytes)
178         cmp     $32, %rdx
179         jb      L(less32bytesin128)
181         movdqu  (%rdi), %xmm2
182         pxor    (%rsi), %xmm2
183         ptest   %xmm2, %xmm0
184         jnc     L(16bytesin256)
186         movdqu  16(%rdi), %xmm2
187         pxor    16(%rsi), %xmm2
188         ptest   %xmm2, %xmm0
189         jnc     L(32bytesin256)
190         sub     $32, %rdx
191         add     $32, %rdi
192         add     $32, %rsi
193 L(less32bytesin128):
194         add     %rdx, %rsi
195         add     %rdx, %rdi
196         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
198 L(less512bytes):
199         sub     $256, %rdx
200         movdqu  (%rdi), %xmm2
201         pxor    (%rsi), %xmm2
202         ptest   %xmm2, %xmm0
203         jnc     L(16bytesin256)
205         movdqu  16(%rdi), %xmm2
206         pxor    16(%rsi), %xmm2
207         ptest   %xmm2, %xmm0
208         jnc     L(32bytesin256)
210         movdqu  32(%rdi), %xmm2
211         pxor    32(%rsi), %xmm2
212         ptest   %xmm2, %xmm0
213         jnc     L(48bytesin256)
215         movdqu  48(%rdi), %xmm2
216         pxor    48(%rsi), %xmm2
217         ptest   %xmm2, %xmm0
218         jnc     L(64bytesin256)
220         movdqu  64(%rdi), %xmm2
221         pxor    64(%rsi), %xmm2
222         ptest   %xmm2, %xmm0
223         jnc     L(80bytesin256)
225         movdqu  80(%rdi), %xmm2
226         pxor    80(%rsi), %xmm2
227         ptest   %xmm2, %xmm0
228         jnc     L(96bytesin256)
230         movdqu  96(%rdi), %xmm2
231         pxor    96(%rsi), %xmm2
232         ptest   %xmm2, %xmm0
233         jnc     L(112bytesin256)
235         movdqu  112(%rdi), %xmm2
236         pxor    112(%rsi), %xmm2
237         ptest   %xmm2, %xmm0
238         jnc     L(128bytesin256)
240         movdqu  128(%rdi), %xmm2
241         pxor    128(%rsi), %xmm2
242         ptest   %xmm2, %xmm0
243         jnc     L(144bytesin256)
245         movdqu  144(%rdi), %xmm2
246         pxor    144(%rsi), %xmm2
247         ptest   %xmm2, %xmm0
248         jnc     L(160bytesin256)
250         movdqu  160(%rdi), %xmm2
251         pxor    160(%rsi), %xmm2
252         ptest   %xmm2, %xmm0
253         jnc     L(176bytesin256)
255         movdqu  176(%rdi), %xmm2
256         pxor    176(%rsi), %xmm2
257         ptest   %xmm2, %xmm0
258         jnc     L(192bytesin256)
260         movdqu  192(%rdi), %xmm2
261         pxor    192(%rsi), %xmm2
262         ptest   %xmm2, %xmm0
263         jnc     L(208bytesin256)
265         movdqu  208(%rdi), %xmm2
266         pxor    208(%rsi), %xmm2
267         ptest   %xmm2, %xmm0
268         jnc     L(224bytesin256)
270         movdqu  224(%rdi), %xmm2
271         pxor    224(%rsi), %xmm2
272         ptest   %xmm2, %xmm0
273         jnc     L(240bytesin256)
275         movdqu  240(%rdi), %xmm2
276         pxor    240(%rsi), %xmm2
277         ptest   %xmm2, %xmm0
278         jnc     L(256bytesin256)
280         add     $256, %rsi
281         add     $256, %rdi
283         cmp     $128, %rdx
284         jae     L(less256bytes)
286         cmp     $64, %rdx
287         jae     L(less128bytes)
289         cmp     $32, %rdx
290         jb      L(less32bytesin256)
292         movdqu  (%rdi), %xmm2
293         pxor    (%rsi), %xmm2
294         ptest   %xmm2, %xmm0
295         jnc     L(16bytesin256)
297         movdqu  16(%rdi), %xmm2
298         pxor    16(%rsi), %xmm2
299         ptest   %xmm2, %xmm0
300         jnc     L(32bytesin256)
301         sub     $32, %rdx
302         add     $32, %rdi
303         add     $32, %rsi
304 L(less32bytesin256):
305         add     %rdx, %rsi
306         add     %rdx, %rdi
307         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
309         ALIGN (4)
310 L(512bytesormore):
311 #ifdef DATA_CACHE_SIZE_HALF
312         mov     $DATA_CACHE_SIZE_HALF, %r8
313 #else
314         mov     __x86_64_data_cache_size_half(%rip), %r8
315 #endif
316         mov     %r8, %r9
317         shr     $1, %r8
318         add     %r9, %r8
319         cmp     %r8, %rdx
320         ja      L(L2_L3_cache_unaglined)
321         sub     $64, %rdx
322         ALIGN (4)
323 L(64bytesormore_loop):
324         movdqu  (%rdi), %xmm2
325         pxor    (%rsi), %xmm2
326         movdqa  %xmm2, %xmm1
328         movdqu  16(%rdi), %xmm3
329         pxor    16(%rsi), %xmm3
330         por     %xmm3, %xmm1
332         movdqu  32(%rdi), %xmm4
333         pxor    32(%rsi), %xmm4
334         por     %xmm4, %xmm1
336         movdqu  48(%rdi), %xmm5
337         pxor    48(%rsi), %xmm5
338         por     %xmm5, %xmm1
340         ptest   %xmm1, %xmm0
341         jnc     L(64bytesormore_loop_end)
342         add     $64, %rsi
343         add     $64, %rdi
344         sub     $64, %rdx
345         jae     L(64bytesormore_loop)
347         add     $64, %rdx
348         add     %rdx, %rsi
349         add     %rdx, %rdi
350         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
352 L(L2_L3_cache_unaglined):
353         sub     $64, %rdx
354         ALIGN (4)
355 L(L2_L3_unaligned_128bytes_loop):
356         prefetchnta 0x1c0(%rdi)
357         prefetchnta 0x1c0(%rsi)
358         movdqu  (%rdi), %xmm2
359         pxor    (%rsi), %xmm2
360         movdqa  %xmm2, %xmm1
362         movdqu  16(%rdi), %xmm3
363         pxor    16(%rsi), %xmm3
364         por     %xmm3, %xmm1
366         movdqu  32(%rdi), %xmm4
367         pxor    32(%rsi), %xmm4
368         por     %xmm4, %xmm1
370         movdqu  48(%rdi), %xmm5
371         pxor    48(%rsi), %xmm5
372         por     %xmm5, %xmm1
374         ptest   %xmm1, %xmm0
375         jnc     L(64bytesormore_loop_end)
376         add     $64, %rsi
377         add     $64, %rdi
378         sub     $64, %rdx
379         jae     L(L2_L3_unaligned_128bytes_loop)
381         add     $64, %rdx
382         add     %rdx, %rsi
383         add     %rdx, %rdi
384         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
387  * This case is for machines which are sensitive for unaligned instructions.
388  */
389         ALIGN (4)
390 L(2aligned):
391         cmp     $128, %rdx
392         ja      L(128bytesormorein2aligned)
393 L(less128bytesin2aligned):
394         sub     $64, %rdx
396         movdqa  (%rdi), %xmm2
397         pxor    (%rsi), %xmm2
398         ptest   %xmm2, %xmm0
399         jnc     L(16bytesin256)
401         movdqa  16(%rdi), %xmm2
402         pxor    16(%rsi), %xmm2
403         ptest   %xmm2, %xmm0
404         jnc     L(32bytesin256)
406         movdqa  32(%rdi), %xmm2
407         pxor    32(%rsi), %xmm2
408         ptest   %xmm2, %xmm0
409         jnc     L(48bytesin256)
411         movdqa  48(%rdi), %xmm2
412         pxor    48(%rsi), %xmm2
413         ptest   %xmm2, %xmm0
414         jnc     L(64bytesin256)
415         cmp     $32, %rdx
416         jb      L(less32bytesin64in2alinged)
418         movdqa  64(%rdi), %xmm2
419         pxor    64(%rsi), %xmm2
420         ptest   %xmm2, %xmm0
421         jnc     L(80bytesin256)
423         movdqa  80(%rdi), %xmm2
424         pxor    80(%rsi), %xmm2
425         ptest   %xmm2, %xmm0
426         jnc     L(96bytesin256)
427         sub     $32, %rdx
428         add     $32, %rdi
429         add     $32, %rsi
430 L(less32bytesin64in2alinged):
431         add     $64, %rdi
432         add     $64, %rsi
433         add     %rdx, %rsi
434         add     %rdx, %rdi
435         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
437         ALIGN (4)
438 L(128bytesormorein2aligned):
439         cmp     $512, %rdx
440         ja      L(512bytesormorein2aligned)
441         cmp     $256, %rdx
442         ja      L(256bytesormorein2aligned)
443 L(less256bytesin2alinged):
444         sub     $128, %rdx
446         movdqa  (%rdi), %xmm2
447         pxor    (%rsi), %xmm2
448         ptest   %xmm2, %xmm0
449         jnc     L(16bytesin256)
451         movdqa  16(%rdi), %xmm2
452         pxor    16(%rsi), %xmm2
453         ptest   %xmm2, %xmm0
454         jnc     L(32bytesin256)
456         movdqa  32(%rdi), %xmm2
457         pxor    32(%rsi), %xmm2
458         ptest   %xmm2, %xmm0
459         jnc     L(48bytesin256)
461         movdqa  48(%rdi), %xmm2
462         pxor    48(%rsi), %xmm2
463         ptest   %xmm2, %xmm0
464         jnc     L(64bytesin256)
466         movdqa  64(%rdi), %xmm2
467         pxor    64(%rsi), %xmm2
468         ptest   %xmm2, %xmm0
469         jnc     L(80bytesin256)
471         movdqa  80(%rdi), %xmm2
472         pxor    80(%rsi), %xmm2
473         ptest   %xmm2, %xmm0
474         jnc     L(96bytesin256)
476         movdqa  96(%rdi), %xmm2
477         pxor    96(%rsi), %xmm2
478         ptest   %xmm2, %xmm0
479         jnc     L(112bytesin256)
481         movdqa  112(%rdi), %xmm2
482         pxor    112(%rsi), %xmm2
483         ptest   %xmm2, %xmm0
484         jnc     L(128bytesin256)
486         add     $128, %rsi
487         add     $128, %rdi
489         cmp     $64, %rdx
490         jae     L(less128bytesin2aligned)
492         cmp     $32, %rdx
493         jb      L(less32bytesin128in2aligned)
495         movdqu  (%rdi), %xmm2
496         pxor    (%rsi), %xmm2
497         ptest   %xmm2, %xmm0
498         jnc     L(16bytesin256)
500         movdqu  16(%rdi), %xmm2
501         pxor    16(%rsi), %xmm2
502         ptest   %xmm2, %xmm0
503         jnc     L(32bytesin256)
504         sub     $32, %rdx
505         add     $32, %rdi
506         add     $32, %rsi
507 L(less32bytesin128in2aligned):
508         add     %rdx, %rsi
509         add     %rdx, %rdi
510         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
512         ALIGN (4)
513 L(256bytesormorein2aligned):
515         sub     $256, %rdx
516         movdqa  (%rdi), %xmm2
517         pxor    (%rsi), %xmm2
518         ptest   %xmm2, %xmm0
519         jnc     L(16bytesin256)
521         movdqa  16(%rdi), %xmm2
522         pxor    16(%rsi), %xmm2
523         ptest   %xmm2, %xmm0
524         jnc     L(32bytesin256)
526         movdqa  32(%rdi), %xmm2
527         pxor    32(%rsi), %xmm2
528         ptest   %xmm2, %xmm0
529         jnc     L(48bytesin256)
531         movdqa  48(%rdi), %xmm2
532         pxor    48(%rsi), %xmm2
533         ptest   %xmm2, %xmm0
534         jnc     L(64bytesin256)
536         movdqa  64(%rdi), %xmm2
537         pxor    64(%rsi), %xmm2
538         ptest   %xmm2, %xmm0
539         jnc     L(80bytesin256)
541         movdqa  80(%rdi), %xmm2
542         pxor    80(%rsi), %xmm2
543         ptest   %xmm2, %xmm0
544         jnc     L(96bytesin256)
546         movdqa  96(%rdi), %xmm2
547         pxor    96(%rsi), %xmm2
548         ptest   %xmm2, %xmm0
549         jnc     L(112bytesin256)
551         movdqa  112(%rdi), %xmm2
552         pxor    112(%rsi), %xmm2
553         ptest   %xmm2, %xmm0
554         jnc     L(128bytesin256)
556         movdqa  128(%rdi), %xmm2
557         pxor    128(%rsi), %xmm2
558         ptest   %xmm2, %xmm0
559         jnc     L(144bytesin256)
561         movdqa  144(%rdi), %xmm2
562         pxor    144(%rsi), %xmm2
563         ptest   %xmm2, %xmm0
564         jnc     L(160bytesin256)
566         movdqa  160(%rdi), %xmm2
567         pxor    160(%rsi), %xmm2
568         ptest   %xmm2, %xmm0
569         jnc     L(176bytesin256)
571         movdqa  176(%rdi), %xmm2
572         pxor    176(%rsi), %xmm2
573         ptest   %xmm2, %xmm0
574         jnc     L(192bytesin256)
576         movdqa  192(%rdi), %xmm2
577         pxor    192(%rsi), %xmm2
578         ptest   %xmm2, %xmm0
579         jnc     L(208bytesin256)
581         movdqa  208(%rdi), %xmm2
582         pxor    208(%rsi), %xmm2
583         ptest   %xmm2, %xmm0
584         jnc     L(224bytesin256)
586         movdqa  224(%rdi), %xmm2
587         pxor    224(%rsi), %xmm2
588         ptest   %xmm2, %xmm0
589         jnc     L(240bytesin256)
591         movdqa  240(%rdi), %xmm2
592         pxor    240(%rsi), %xmm2
593         ptest   %xmm2, %xmm0
594         jnc     L(256bytesin256)
596         add     $256, %rsi
597         add     $256, %rdi
599         cmp     $128, %rdx
600         jae     L(less256bytesin2alinged)
602         cmp     $64, %rdx
603         jae     L(less128bytesin2aligned)
605         cmp     $32, %rdx
606         jb      L(less32bytesin256in2alinged)
608         movdqa  (%rdi), %xmm2
609         pxor    (%rsi), %xmm2
610         ptest   %xmm2, %xmm0
611         jnc     L(16bytesin256)
613         movdqa  16(%rdi), %xmm2
614         pxor    16(%rsi), %xmm2
615         ptest   %xmm2, %xmm0
616         jnc     L(32bytesin256)
617         sub     $32, %rdx
618         add     $32, %rdi
619         add     $32, %rsi
620 L(less32bytesin256in2alinged):
621         add     %rdx, %rsi
622         add     %rdx, %rdi
623         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
625         ALIGN (4)
626 L(512bytesormorein2aligned):
627 #ifdef SHARED_CACHE_SIZE_HALF
628         mov     $DATA_CACHE_SIZE_HALF, %r8
629 #else
630         mov     __x86_64_data_cache_size_half(%rip), %r8
631 #endif
632         mov     %r8, %r9
633         shr     $1, %r8
634         add     %r9, %r8
635         cmp     %r8, %rdx
636         ja      L(L2_L3_cache_aglined)
638         sub     $64, %rdx
639         ALIGN (4)
640 L(64bytesormore_loopin2aligned):
641         movdqa  (%rdi), %xmm2
642         pxor    (%rsi), %xmm2
643         movdqa  %xmm2, %xmm1
645         movdqa  16(%rdi), %xmm3
646         pxor    16(%rsi), %xmm3
647         por     %xmm3, %xmm1
649         movdqa  32(%rdi), %xmm4
650         pxor    32(%rsi), %xmm4
651         por     %xmm4, %xmm1
653         movdqa  48(%rdi), %xmm5
654         pxor    48(%rsi), %xmm5
655         por     %xmm5, %xmm1
657         ptest   %xmm1, %xmm0
658         jnc     L(64bytesormore_loop_end)
659         add     $64, %rsi
660         add     $64, %rdi
661         sub     $64, %rdx
662         jae     L(64bytesormore_loopin2aligned)
664         add     $64, %rdx
665         add     %rdx, %rsi
666         add     %rdx, %rdi
667         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
668 L(L2_L3_cache_aglined):
669         sub     $64, %rdx
670         ALIGN (4)
671 L(L2_L3_aligned_128bytes_loop):
672         prefetchnta 0x1c0(%rdi)
673         prefetchnta 0x1c0(%rsi)
674         movdqa  (%rdi), %xmm2
675         pxor    (%rsi), %xmm2
676         movdqa  %xmm2, %xmm1
678         movdqa  16(%rdi), %xmm3
679         pxor    16(%rsi), %xmm3
680         por     %xmm3, %xmm1
682         movdqa  32(%rdi), %xmm4
683         pxor    32(%rsi), %xmm4
684         por     %xmm4, %xmm1
686         movdqa  48(%rdi), %xmm5
687         pxor    48(%rsi), %xmm5
688         por     %xmm5, %xmm1
690         ptest   %xmm1, %xmm0
691         jnc     L(64bytesormore_loop_end)
692         add     $64, %rsi
693         add     $64, %rdi
694         sub     $64, %rdx
695         jae     L(L2_L3_aligned_128bytes_loop)
697         add     $64, %rdx
698         add     %rdx, %rsi
699         add     %rdx, %rdi
700         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %rdx, 4)
703         ALIGN (4)
704 L(64bytesormore_loop_end):
705         add     $16, %rdi
706         add     $16, %rsi
707         ptest   %xmm2, %xmm0
708         jnc     L(16bytes)
710         add     $16, %rdi
711         add     $16, %rsi
712         ptest   %xmm3, %xmm0
713         jnc     L(16bytes)
715         add     $16, %rdi
716         add     $16, %rsi
717         ptest   %xmm4, %xmm0
718         jnc     L(16bytes)
720         add     $16, %rdi
721         add     $16, %rsi
722         jmp     L(16bytes)
724 L(256bytesin256):
725         add     $256, %rdi
726         add     $256, %rsi
727         jmp     L(16bytes)
728 L(240bytesin256):
729         add     $240, %rdi
730         add     $240, %rsi
731         jmp     L(16bytes)
732 L(224bytesin256):
733         add     $224, %rdi
734         add     $224, %rsi
735         jmp     L(16bytes)
736 L(208bytesin256):
737         add     $208, %rdi
738         add     $208, %rsi
739         jmp     L(16bytes)
740 L(192bytesin256):
741         add     $192, %rdi
742         add     $192, %rsi
743         jmp     L(16bytes)
744 L(176bytesin256):
745         add     $176, %rdi
746         add     $176, %rsi
747         jmp     L(16bytes)
748 L(160bytesin256):
749         add     $160, %rdi
750         add     $160, %rsi
751         jmp     L(16bytes)
752 L(144bytesin256):
753         add     $144, %rdi
754         add     $144, %rsi
755         jmp     L(16bytes)
756 L(128bytesin256):
757         add     $128, %rdi
758         add     $128, %rsi
759         jmp     L(16bytes)
760 L(112bytesin256):
761         add     $112, %rdi
762         add     $112, %rsi
763         jmp     L(16bytes)
764 L(96bytesin256):
765         add     $96, %rdi
766         add     $96, %rsi
767         jmp     L(16bytes)
768 L(80bytesin256):
769         add     $80, %rdi
770         add     $80, %rsi
771         jmp     L(16bytes)
772 L(64bytesin256):
773         add     $64, %rdi
774         add     $64, %rsi
775         jmp     L(16bytes)
776 L(48bytesin256):
777         add     $16, %rdi
778         add     $16, %rsi
779 L(32bytesin256):
780         add     $16, %rdi
781         add     $16, %rsi
782 L(16bytesin256):
783         add     $16, %rdi
784         add     $16, %rsi
785 L(16bytes):
786         mov     -16(%rdi), %rax
787         mov     -16(%rsi), %rcx
788         cmp     %rax, %rcx
789         jne     L(diffin8bytes)
790 L(8bytes):
791         mov     -8(%rdi), %rax
792         mov     -8(%rsi), %rcx
793         cmp     %rax, %rcx
794         jne     L(diffin8bytes)
795         xor     %eax, %eax
796         ret
798         ALIGN (4)
799 L(12bytes):
800         mov     -12(%rdi), %rax
801         mov     -12(%rsi), %rcx
802         cmp     %rax, %rcx
803         jne     L(diffin8bytes)
804 L(4bytes):
805         mov     -4(%rsi), %ecx
806         mov     -4(%rdi), %eax
807         cmp     %eax, %ecx
808         jne     L(diffin4bytes)
809 L(0bytes):
810         xor     %eax, %eax
811         ret
813         ALIGN (4)
814 L(65bytes):
815         movdqu  -65(%rdi), %xmm1
816         movdqu  -65(%rsi), %xmm2
817         mov     $-65, %dl
818         pxor    %xmm1, %xmm2
819         ptest   %xmm2, %xmm0
820         jnc     L(less16bytes)
821 L(49bytes):
822         movdqu  -49(%rdi), %xmm1
823         movdqu  -49(%rsi), %xmm2
824         mov     $-49, %dl
825         pxor    %xmm1, %xmm2
826         ptest   %xmm2, %xmm0
827         jnc     L(less16bytes)
828 L(33bytes):
829         movdqu  -33(%rdi), %xmm1
830         movdqu  -33(%rsi), %xmm2
831         mov     $-33, %dl
832         pxor    %xmm1, %xmm2
833         ptest   %xmm2, %xmm0
834         jnc     L(less16bytes)
835 L(17bytes):
836         mov     -17(%rdi), %rax
837         mov     -17(%rsi), %rcx
838         cmp     %rax, %rcx
839         jne     L(diffin8bytes)
840 L(9bytes):
841         mov     -9(%rdi), %rax
842         mov     -9(%rsi), %rcx
843         cmp     %rax, %rcx
844         jne     L(diffin8bytes)
845         movzbl  -1(%rdi), %eax
846         movzbl  -1(%rsi), %edx
847         sub     %edx, %eax
848         ret
850         ALIGN (4)
851 L(13bytes):
852         mov     -13(%rdi), %rax
853         mov     -13(%rsi), %rcx
854         cmp     %rax, %rcx
855         jne     L(diffin8bytes)
856         mov     -8(%rdi), %rax
857         mov     -8(%rsi), %rcx
858         cmp     %rax, %rcx
859         jne     L(diffin8bytes)
860         xor     %eax, %eax
861         ret
863         ALIGN (4)
864 L(5bytes):
865         mov     -5(%rdi), %eax
866         mov     -5(%rsi), %ecx
867         cmp     %eax, %ecx
868         jne     L(diffin4bytes)
869         movzbl  -1(%rdi), %eax
870         movzbl  -1(%rsi), %edx
871         sub     %edx, %eax
872         ret
874         ALIGN (4)
875 L(66bytes):
876         movdqu  -66(%rdi), %xmm1
877         movdqu  -66(%rsi), %xmm2
878         mov     $-66, %dl
879         pxor    %xmm1, %xmm2
880         ptest   %xmm2, %xmm0
881         jnc     L(less16bytes)
882 L(50bytes):
883         movdqu  -50(%rdi), %xmm1
884         movdqu  -50(%rsi), %xmm2
885         mov     $-50, %dl
886         pxor    %xmm1, %xmm2
887         ptest   %xmm2, %xmm0
888         jnc     L(less16bytes)
889 L(34bytes):
890         movdqu  -34(%rdi), %xmm1
891         movdqu  -34(%rsi), %xmm2
892         mov     $-34, %dl
893         pxor    %xmm1, %xmm2
894         ptest   %xmm2, %xmm0
895         jnc     L(less16bytes)
896 L(18bytes):
897         mov     -18(%rdi), %rax
898         mov     -18(%rsi), %rcx
899         cmp     %rax, %rcx
900         jne     L(diffin8bytes)
901 L(10bytes):
902         mov     -10(%rdi), %rax
903         mov     -10(%rsi), %rcx
904         cmp     %rax, %rcx
905         jne     L(diffin8bytes)
906         movzwl  -2(%rdi), %eax
907         movzwl  -2(%rsi), %ecx
908         cmp     %cl, %al
909         jne     L(end)
910         and     $0xffff, %eax
911         and     $0xffff, %ecx
912         sub     %ecx, %eax
913         ret
915         ALIGN (4)
916 L(14bytes):
917         mov     -14(%rdi), %rax
918         mov     -14(%rsi), %rcx
919         cmp     %rax, %rcx
920         jne     L(diffin8bytes)
921         mov     -8(%rdi), %rax
922         mov     -8(%rsi), %rcx
923         cmp     %rax, %rcx
924         jne     L(diffin8bytes)
925         xor     %eax, %eax
926         ret
928         ALIGN (4)
929 L(6bytes):
930         mov     -6(%rdi), %eax
931         mov     -6(%rsi), %ecx
932         cmp     %eax, %ecx
933         jne     L(diffin4bytes)
934 L(2bytes):
935         movzwl  -2(%rsi), %ecx
936         movzwl  -2(%rdi), %eax
937         cmp     %cl, %al
938         jne     L(end)
939         and     $0xffff, %eax
940         and     $0xffff, %ecx
941         sub     %ecx, %eax
942         ret
944         ALIGN (4)
945 L(67bytes):
946         movdqu  -67(%rdi), %xmm2
947         movdqu  -67(%rsi), %xmm1
948         mov     $-67, %dl
949         pxor    %xmm1, %xmm2
950         ptest   %xmm2, %xmm0
951         jnc     L(less16bytes)
952 L(51bytes):
953         movdqu  -51(%rdi), %xmm2
954         movdqu  -51(%rsi), %xmm1
955         mov     $-51, %dl
956         pxor    %xmm1, %xmm2
957         ptest   %xmm2, %xmm0
958         jnc     L(less16bytes)
959 L(35bytes):
960         movdqu  -35(%rsi), %xmm1
961         movdqu  -35(%rdi), %xmm2
962         mov     $-35, %dl
963         pxor    %xmm1, %xmm2
964         ptest   %xmm2, %xmm0
965         jnc     L(less16bytes)
966 L(19bytes):
967         mov     -19(%rdi), %rax
968         mov     -19(%rsi), %rcx
969         cmp     %rax, %rcx
970         jne     L(diffin8bytes)
971 L(11bytes):
972         mov     -11(%rdi), %rax
973         mov     -11(%rsi), %rcx
974         cmp     %rax, %rcx
975         jne     L(diffin8bytes)
976         mov     -4(%rdi), %eax
977         mov     -4(%rsi), %ecx
978         cmp     %eax, %ecx
979         jne     L(diffin4bytes)
980         xor     %eax, %eax
981         ret
983         ALIGN (4)
984 L(15bytes):
985         mov     -15(%rdi), %rax
986         mov     -15(%rsi), %rcx
987         cmp     %rax, %rcx
988         jne     L(diffin8bytes)
989         mov     -8(%rdi), %rax
990         mov     -8(%rsi), %rcx
991         cmp     %rax, %rcx
992         jne     L(diffin8bytes)
993         xor     %eax, %eax
994         ret
996         ALIGN (4)
997 L(7bytes):
998         mov     -7(%rdi), %eax
999         mov     -7(%rsi), %ecx
1000         cmp     %eax, %ecx
1001         jne     L(diffin4bytes)
1002         mov     -4(%rdi), %eax
1003         mov     -4(%rsi), %ecx
1004         cmp     %eax, %ecx
1005         jne     L(diffin4bytes)
1006         xor     %eax, %eax
1007         ret
1009         ALIGN (4)
1010 L(3bytes):
1011         movzwl  -3(%rdi), %eax
1012         movzwl  -3(%rsi), %ecx
1013         cmp     %eax, %ecx
1014         jne     L(diffin2bytes)
1015 L(1bytes):
1016         movzbl  -1(%rdi), %eax
1017         movzbl  -1(%rsi), %ecx
1018         sub     %ecx, %eax
1019         ret
1021         ALIGN (4)
1022 L(68bytes):
1023         movdqu  -68(%rdi), %xmm2
1024         movdqu  -68(%rsi), %xmm1
1025         mov     $-68, %dl
1026         pxor    %xmm1, %xmm2
1027         ptest   %xmm2, %xmm0
1028         jnc     L(less16bytes)
1029 L(52bytes):
1030         movdqu  -52(%rdi), %xmm2
1031         movdqu  -52(%rsi), %xmm1
1032         mov     $-52, %dl
1033         pxor    %xmm1, %xmm2
1034         ptest   %xmm2, %xmm0
1035         jnc     L(less16bytes)
1036 L(36bytes):
1037         movdqu  -36(%rdi), %xmm2
1038         movdqu  -36(%rsi), %xmm1
1039         mov     $-36, %dl
1040         pxor    %xmm1, %xmm2
1041         ptest   %xmm2, %xmm0
1042         jnc     L(less16bytes)
1043 L(20bytes):
1044         movdqu  -20(%rdi), %xmm2
1045         movdqu  -20(%rsi), %xmm1
1046         mov     $-20, %dl
1047         pxor    %xmm1, %xmm2
1048         ptest   %xmm2, %xmm0
1049         jnc     L(less16bytes)
1050         mov     -4(%rdi), %eax
1051         mov     -4(%rsi), %ecx
1052         cmp     %eax, %ecx
1053         jne     L(diffin4bytes)
1054         xor     %eax, %eax
1055         ret
1057         ALIGN (4)
1058 L(69bytes):
1059         movdqu  -69(%rsi), %xmm1
1060         movdqu  -69(%rdi), %xmm2
1061         mov     $-69, %dl
1062         pxor    %xmm1, %xmm2
1063         ptest   %xmm2, %xmm0
1064         jnc     L(less16bytes)
1065 L(53bytes):
1066         movdqu  -53(%rsi), %xmm1
1067         movdqu  -53(%rdi), %xmm2
1068         mov     $-53, %dl
1069         pxor    %xmm1, %xmm2
1070         ptest   %xmm2, %xmm0
1071         jnc     L(less16bytes)
1072 L(37bytes):
1073         movdqu  -37(%rsi), %xmm1
1074         movdqu  -37(%rdi), %xmm2
1075         mov     $-37, %dl
1076         pxor    %xmm1, %xmm2
1077         ptest   %xmm2, %xmm0
1078         jnc     L(less16bytes)
1079 L(21bytes):
1080         movdqu  -21(%rsi), %xmm1
1081         movdqu  -21(%rdi), %xmm2
1082         mov     $-21, %dl
1083         pxor    %xmm1, %xmm2
1084         ptest   %xmm2, %xmm0
1085         jnc     L(less16bytes)
1086         mov     -8(%rdi), %rax
1087         mov     -8(%rsi), %rcx
1088         cmp     %rax, %rcx
1089         jne     L(diffin8bytes)
1090         xor     %eax, %eax
1091         ret
1093         ALIGN (4)
1094 L(70bytes):
1095         movdqu  -70(%rsi), %xmm1
1096         movdqu  -70(%rdi), %xmm2
1097         mov     $-70, %dl
1098         pxor    %xmm1, %xmm2
1099         ptest   %xmm2, %xmm0
1100         jnc     L(less16bytes)
1101 L(54bytes):
1102         movdqu  -54(%rsi), %xmm1
1103         movdqu  -54(%rdi), %xmm2
1104         mov     $-54, %dl
1105         pxor    %xmm1, %xmm2
1106         ptest   %xmm2, %xmm0
1107         jnc     L(less16bytes)
1108 L(38bytes):
1109         movdqu  -38(%rsi), %xmm1
1110         movdqu  -38(%rdi), %xmm2
1111         mov     $-38, %dl
1112         pxor    %xmm1, %xmm2
1113         ptest   %xmm2, %xmm0
1114         jnc     L(less16bytes)
1115 L(22bytes):
1116         movdqu  -22(%rsi), %xmm1
1117         movdqu  -22(%rdi), %xmm2
1118         mov     $-22, %dl
1119         pxor    %xmm1, %xmm2
1120         ptest   %xmm2, %xmm0
1121         jnc     L(less16bytes)
1122         mov     -8(%rdi), %rax
1123         mov     -8(%rsi), %rcx
1124         cmp     %rax, %rcx
1125         jne     L(diffin8bytes)
1126         xor     %eax, %eax
1127         ret
1129         ALIGN (4)
1130 L(71bytes):
1131         movdqu  -71(%rsi), %xmm1
1132         movdqu  -71(%rdi), %xmm2
1133         mov     $-71, %dl
1134         pxor    %xmm1, %xmm2
1135         ptest   %xmm2, %xmm0
1136         jnc     L(less16bytes)
1137 L(55bytes):
1138         movdqu  -55(%rdi), %xmm2
1139         movdqu  -55(%rsi), %xmm1
1140         mov     $-55, %dl
1141         pxor    %xmm1, %xmm2
1142         ptest   %xmm2, %xmm0
1143         jnc     L(less16bytes)
1144 L(39bytes):
1145         movdqu  -39(%rdi), %xmm2
1146         movdqu  -39(%rsi), %xmm1
1147         mov     $-39, %dl
1148         pxor    %xmm1, %xmm2
1149         ptest   %xmm2, %xmm0
1150         jnc     L(less16bytes)
1151 L(23bytes):
1152         movdqu  -23(%rdi), %xmm2
1153         movdqu  -23(%rsi), %xmm1
1154         mov     $-23, %dl
1155         pxor    %xmm1, %xmm2
1156         ptest   %xmm2, %xmm0
1157         jnc     L(less16bytes)
1158         mov     -8(%rdi), %rax
1159         mov     -8(%rsi), %rcx
1160         cmp     %rax, %rcx
1161         jne     L(diffin8bytes)
1162         xor     %eax, %eax
1163         ret
1165         ALIGN (4)
1166 L(72bytes):
1167         movdqu  -72(%rsi), %xmm1
1168         movdqu  -72(%rdi), %xmm2
1169         mov     $-72, %dl
1170         pxor    %xmm1, %xmm2
1171         ptest   %xmm2, %xmm0
1172         jnc     L(less16bytes)
1173 L(56bytes):
1174         movdqu  -56(%rdi), %xmm2
1175         movdqu  -56(%rsi), %xmm1
1176         mov     $-56, %dl
1177         pxor    %xmm1, %xmm2
1178         ptest   %xmm2, %xmm0
1179         jnc     L(less16bytes)
1180 L(40bytes):
1181         movdqu  -40(%rdi), %xmm2
1182         movdqu  -40(%rsi), %xmm1
1183         mov     $-40, %dl
1184         pxor    %xmm1, %xmm2
1185         ptest   %xmm2, %xmm0
1186         jnc     L(less16bytes)
1187 L(24bytes):
1188         movdqu  -24(%rdi), %xmm2
1189         movdqu  -24(%rsi), %xmm1
1190         mov     $-24, %dl
1191         pxor    %xmm1, %xmm2
1192         ptest   %xmm2, %xmm0
1193         jnc     L(less16bytes)
1194         mov     -8(%rdi), %rax
1195         mov     -8(%rsi), %rcx
1196         cmp     %rax, %rcx
1197         jne     L(diffin8bytes)
1198         xor     %eax, %eax
1199         ret
1201         ALIGN (4)
1202 L(73bytes):
1203         movdqu  -73(%rsi), %xmm1
1204         movdqu  -73(%rdi), %xmm2
1205         mov     $-73, %dl
1206         pxor    %xmm1, %xmm2
1207         ptest   %xmm2, %xmm0
1208         jnc     L(less16bytes)
1209 L(57bytes):
1210         movdqu  -57(%rdi), %xmm2
1211         movdqu  -57(%rsi), %xmm1
1212         mov     $-57, %dl
1213         pxor    %xmm1, %xmm2
1214         ptest   %xmm2, %xmm0
1215         jnc     L(less16bytes)
1216 L(41bytes):
1217         movdqu  -41(%rdi), %xmm2
1218         movdqu  -41(%rsi), %xmm1
1219         mov     $-41, %dl
1220         pxor    %xmm1, %xmm2
1221         ptest   %xmm2, %xmm0
1222         jnc     L(less16bytes)
1223 L(25bytes):
1224         movdqu  -25(%rdi), %xmm2
1225         movdqu  -25(%rsi), %xmm1
1226         mov     $-25, %dl
1227         pxor    %xmm1, %xmm2
1228         ptest   %xmm2, %xmm0
1229         jnc     L(less16bytes)
1230         mov     -9(%rdi), %rax
1231         mov     -9(%rsi), %rcx
1232         cmp     %rax, %rcx
1233         jne     L(diffin8bytes)
1234         movzbl  -1(%rdi), %eax
1235         movzbl  -1(%rsi), %ecx
1236         sub     %ecx, %eax
1237         ret
1239         ALIGN (4)
1240 L(74bytes):
1241         movdqu  -74(%rsi), %xmm1
1242         movdqu  -74(%rdi), %xmm2
1243         mov     $-74, %dl
1244         pxor    %xmm1, %xmm2
1245         ptest   %xmm2, %xmm0
1246         jnc     L(less16bytes)
1247 L(58bytes):
1248         movdqu  -58(%rdi), %xmm2
1249         movdqu  -58(%rsi), %xmm1
1250         mov     $-58, %dl
1251         pxor    %xmm1, %xmm2
1252         ptest   %xmm2, %xmm0
1253         jnc     L(less16bytes)
1254 L(42bytes):
1255         movdqu  -42(%rdi), %xmm2
1256         movdqu  -42(%rsi), %xmm1
1257         mov     $-42, %dl
1258         pxor    %xmm1, %xmm2
1259         ptest   %xmm2, %xmm0
1260         jnc     L(less16bytes)
1261 L(26bytes):
1262         movdqu  -26(%rdi), %xmm2
1263         movdqu  -26(%rsi), %xmm1
1264         mov     $-26, %dl
1265         pxor    %xmm1, %xmm2
1266         ptest   %xmm2, %xmm0
1267         jnc     L(less16bytes)
1268         mov     -10(%rdi), %rax
1269         mov     -10(%rsi), %rcx
1270         cmp     %rax, %rcx
1271         jne     L(diffin8bytes)
1272         movzwl  -2(%rdi), %eax
1273         movzwl  -2(%rsi), %ecx
1274         jmp     L(diffin2bytes)
1276         ALIGN (4)
1277 L(75bytes):
1278         movdqu  -75(%rsi), %xmm1
1279         movdqu  -75(%rdi), %xmm2
1280         mov     $-75, %dl
1281         pxor    %xmm1, %xmm2
1282         ptest   %xmm2, %xmm0
1283         jnc     L(less16bytes)
1284 L(59bytes):
1285         movdqu  -59(%rdi), %xmm2
1286         movdqu  -59(%rsi), %xmm1
1287         mov     $-59, %dl
1288         pxor    %xmm1, %xmm2
1289         ptest   %xmm2, %xmm0
1290         jnc     L(less16bytes)
1291 L(43bytes):
1292         movdqu  -43(%rdi), %xmm2
1293         movdqu  -43(%rsi), %xmm1
1294         mov     $-43, %dl
1295         pxor    %xmm1, %xmm2
1296         ptest   %xmm2, %xmm0
1297         jnc     L(less16bytes)
1298 L(27bytes):
1299         movdqu  -27(%rdi), %xmm2
1300         movdqu  -27(%rsi), %xmm1
1301         mov     $-27, %dl
1302         pxor    %xmm1, %xmm2
1303         ptest   %xmm2, %xmm0
1304         jnc     L(less16bytes)
1305         mov     -11(%rdi), %rax
1306         mov     -11(%rsi), %rcx
1307         cmp     %rax, %rcx
1308         jne     L(diffin8bytes)
1309         mov     -4(%rdi), %eax
1310         mov     -4(%rsi), %ecx
1311         cmp     %eax, %ecx
1312         jne     L(diffin4bytes)
1313         xor     %eax, %eax
1314         ret
1316         ALIGN (4)
1317 L(76bytes):
1318         movdqu  -76(%rsi), %xmm1
1319         movdqu  -76(%rdi), %xmm2
1320         mov     $-76, %dl
1321         pxor    %xmm1, %xmm2
1322         ptest   %xmm2, %xmm0
1323         jnc     L(less16bytes)
1324 L(60bytes):
1325         movdqu  -60(%rdi), %xmm2
1326         movdqu  -60(%rsi), %xmm1
1327         mov     $-60, %dl
1328         pxor    %xmm1, %xmm2
1329         ptest   %xmm2, %xmm0
1330         jnc     L(less16bytes)
1331 L(44bytes):
1332         movdqu  -44(%rdi), %xmm2
1333         movdqu  -44(%rsi), %xmm1
1334         mov     $-44, %dl
1335         pxor    %xmm1, %xmm2
1336         ptest   %xmm2, %xmm0
1337         jnc     L(less16bytes)
1338 L(28bytes):
1339         movdqu  -28(%rdi), %xmm2
1340         movdqu  -28(%rsi), %xmm1
1341         mov     $-28, %dl
1342         pxor    %xmm1, %xmm2
1343         ptest   %xmm2, %xmm0
1344         jnc     L(less16bytes)
1345         mov     -12(%rdi), %rax
1346         mov     -12(%rsi), %rcx
1347         cmp     %rax, %rcx
1348         jne     L(diffin8bytes)
1349         mov     -4(%rdi), %eax
1350         mov     -4(%rsi), %ecx
1351         cmp     %eax, %ecx
1352         jne     L(diffin4bytes)
1353         xor     %eax, %eax
1354         ret
1356         ALIGN (4)
1357 L(77bytes):
1358         movdqu  -77(%rsi), %xmm1
1359         movdqu  -77(%rdi), %xmm2
1360         mov     $-77, %dl
1361         pxor    %xmm1, %xmm2
1362         ptest   %xmm2, %xmm0
1363         jnc     L(less16bytes)
1364 L(61bytes):
1365         movdqu  -61(%rdi), %xmm2
1366         movdqu  -61(%rsi), %xmm1
1367         mov     $-61, %dl
1368         pxor    %xmm1, %xmm2
1369         ptest   %xmm2, %xmm0
1370         jnc     L(less16bytes)
1371 L(45bytes):
1372         movdqu  -45(%rdi), %xmm2
1373         movdqu  -45(%rsi), %xmm1
1374         mov     $-45, %dl
1375         pxor    %xmm1, %xmm2
1376         ptest   %xmm2, %xmm0
1377         jnc     L(less16bytes)
1378 L(29bytes):
1379         movdqu  -29(%rdi), %xmm2
1380         movdqu  -29(%rsi), %xmm1
1381         mov     $-29, %dl
1382         pxor    %xmm1, %xmm2
1383         ptest   %xmm2, %xmm0
1384         jnc     L(less16bytes)
1386         mov     -13(%rdi), %rax
1387         mov     -13(%rsi), %rcx
1388         cmp     %rax, %rcx
1389         jne     L(diffin8bytes)
1391         mov     -8(%rdi), %rax
1392         mov     -8(%rsi), %rcx
1393         cmp     %rax, %rcx
1394         jne     L(diffin8bytes)
1395         xor     %eax, %eax
1396         ret
1398         ALIGN (4)
1399 L(78bytes):
1400         movdqu  -78(%rsi), %xmm1
1401         movdqu  -78(%rdi), %xmm2
1402         mov     $-78, %dl
1403         pxor    %xmm1, %xmm2
1404         ptest   %xmm2, %xmm0
1405         jnc     L(less16bytes)
1406 L(62bytes):
1407         movdqu  -62(%rdi), %xmm2
1408         movdqu  -62(%rsi), %xmm1
1409         mov     $-62, %dl
1410         pxor    %xmm1, %xmm2
1411         ptest   %xmm2, %xmm0
1412         jnc     L(less16bytes)
1413 L(46bytes):
1414         movdqu  -46(%rdi), %xmm2
1415         movdqu  -46(%rsi), %xmm1
1416         mov     $-46, %dl
1417         pxor    %xmm1, %xmm2
1418         ptest   %xmm2, %xmm0
1419         jnc     L(less16bytes)
1420 L(30bytes):
1421         movdqu  -30(%rdi), %xmm2
1422         movdqu  -30(%rsi), %xmm1
1423         mov     $-30, %dl
1424         pxor    %xmm1, %xmm2
1425         ptest   %xmm2, %xmm0
1426         jnc     L(less16bytes)
1427         mov     -14(%rdi), %rax
1428         mov     -14(%rsi), %rcx
1429         cmp     %rax, %rcx
1430         jne     L(diffin8bytes)
1431         mov     -8(%rdi), %rax
1432         mov     -8(%rsi), %rcx
1433         cmp     %rax, %rcx
1434         jne     L(diffin8bytes)
1435         xor     %eax, %eax
1436         ret
1438         ALIGN (4)
1439 L(79bytes):
1440         movdqu  -79(%rsi), %xmm1
1441         movdqu  -79(%rdi), %xmm2
1442         mov     $-79, %dl
1443         pxor    %xmm1, %xmm2
1444         ptest   %xmm2, %xmm0
1445         jnc     L(less16bytes)
1446 L(63bytes):
1447         movdqu  -63(%rdi), %xmm2
1448         movdqu  -63(%rsi), %xmm1
1449         mov     $-63, %dl
1450         pxor    %xmm1, %xmm2
1451         ptest   %xmm2, %xmm0
1452         jnc     L(less16bytes)
1453 L(47bytes):
1454         movdqu  -47(%rdi), %xmm2
1455         movdqu  -47(%rsi), %xmm1
1456         mov     $-47, %dl
1457         pxor    %xmm1, %xmm2
1458         ptest   %xmm2, %xmm0
1459         jnc     L(less16bytes)
1460 L(31bytes):
1461         movdqu  -31(%rdi), %xmm2
1462         movdqu  -31(%rsi), %xmm1
1463         mov     $-31, %dl
1464         pxor    %xmm1, %xmm2
1465         ptest   %xmm2, %xmm0
1466         jnc     L(less16bytes)
1467         mov     -15(%rdi), %rax
1468         mov     -15(%rsi), %rcx
1469         cmp     %rax, %rcx
1470         jne     L(diffin8bytes)
1471         mov     -8(%rdi), %rax
1472         mov     -8(%rsi), %rcx
1473         cmp     %rax, %rcx
1474         jne     L(diffin8bytes)
1475         xor     %eax, %eax
1476         ret
1478         ALIGN (4)
1479 L(64bytes):
1480         movdqu  -64(%rdi), %xmm2
1481         movdqu  -64(%rsi), %xmm1
1482         mov     $-64, %dl
1483         pxor    %xmm1, %xmm2
1484         ptest   %xmm2, %xmm0
1485         jnc     L(less16bytes)
1486 L(48bytes):
1487         movdqu  -48(%rdi), %xmm2
1488         movdqu  -48(%rsi), %xmm1
1489         mov     $-48, %dl
1490         pxor    %xmm1, %xmm2
1491         ptest   %xmm2, %xmm0
1492         jnc     L(less16bytes)
1493 L(32bytes):
1494         movdqu  -32(%rdi), %xmm2
1495         movdqu  -32(%rsi), %xmm1
1496         mov     $-32, %dl
1497         pxor    %xmm1, %xmm2
1498         ptest   %xmm2, %xmm0
1499         jnc     L(less16bytes)
1501         mov     -16(%rdi), %rax
1502         mov     -16(%rsi), %rcx
1503         cmp     %rax, %rcx
1504         jne     L(diffin8bytes)
1506         mov     -8(%rdi), %rax
1507         mov     -8(%rsi), %rcx
1508         cmp     %rax, %rcx
1509         jne     L(diffin8bytes)
1510         xor     %eax, %eax
1511         ret
1514  * Aligned 8 bytes to avoid 2 branch "taken" in one 16 alinged code block.
1515  */
1516         ALIGN (3)
1517 L(less16bytes):
1518         movsbq  %dl, %rdx
1519         mov     (%rsi, %rdx), %rcx
1520         mov     (%rdi, %rdx), %rax
1521         cmp     %rax, %rcx
1522         jne     L(diffin8bytes)
1523         mov     8(%rsi, %rdx), %rcx
1524         mov     8(%rdi, %rdx), %rax
1525 L(diffin8bytes):
1526         cmp     %eax, %ecx
1527         jne     L(diffin4bytes)
1528         shr     $32, %rcx
1529         shr     $32, %rax
1530 L(diffin4bytes):
1531         cmp     %cx, %ax
1532         jne     L(diffin2bytes)
1533         shr     $16, %ecx
1534         shr     $16, %eax
1535 L(diffin2bytes):
1536         cmp     %cl, %al
1537         jne     L(end)
1538         and     $0xffff, %eax
1539         and     $0xffff, %ecx
1540         sub     %ecx, %eax
1541         ret
1543         ALIGN (4)
1544 L(end):
1545         and     $0xff, %eax
1546         and     $0xff, %ecx
1547         sub     %ecx, %eax
1548         ret
1550 END (MEMCMP)
1552         .section .rodata.sse4.1,"a",@progbits
1553         ALIGN (3)
1554 L(table_64bytes):
1555         .int    JMPTBL (L(0bytes), L(table_64bytes))
1556         .int    JMPTBL (L(1bytes), L(table_64bytes))
1557         .int    JMPTBL (L(2bytes), L(table_64bytes))
1558         .int    JMPTBL (L(3bytes), L(table_64bytes))
1559         .int    JMPTBL (L(4bytes), L(table_64bytes))
1560         .int    JMPTBL (L(5bytes), L(table_64bytes))
1561         .int    JMPTBL (L(6bytes), L(table_64bytes))
1562         .int    JMPTBL (L(7bytes), L(table_64bytes))
1563         .int    JMPTBL (L(8bytes), L(table_64bytes))
1564         .int    JMPTBL (L(9bytes), L(table_64bytes))
1565         .int    JMPTBL (L(10bytes), L(table_64bytes))
1566         .int    JMPTBL (L(11bytes), L(table_64bytes))
1567         .int    JMPTBL (L(12bytes), L(table_64bytes))
1568         .int    JMPTBL (L(13bytes), L(table_64bytes))
1569         .int    JMPTBL (L(14bytes), L(table_64bytes))
1570         .int    JMPTBL (L(15bytes), L(table_64bytes))
1571         .int    JMPTBL (L(16bytes), L(table_64bytes))
1572         .int    JMPTBL (L(17bytes), L(table_64bytes))
1573         .int    JMPTBL (L(18bytes), L(table_64bytes))
1574         .int    JMPTBL (L(19bytes), L(table_64bytes))
1575         .int    JMPTBL (L(20bytes), L(table_64bytes))
1576         .int    JMPTBL (L(21bytes), L(table_64bytes))
1577         .int    JMPTBL (L(22bytes), L(table_64bytes))
1578         .int    JMPTBL (L(23bytes), L(table_64bytes))
1579         .int    JMPTBL (L(24bytes), L(table_64bytes))
1580         .int    JMPTBL (L(25bytes), L(table_64bytes))
1581         .int    JMPTBL (L(26bytes), L(table_64bytes))
1582         .int    JMPTBL (L(27bytes), L(table_64bytes))
1583         .int    JMPTBL (L(28bytes), L(table_64bytes))
1584         .int    JMPTBL (L(29bytes), L(table_64bytes))
1585         .int    JMPTBL (L(30bytes), L(table_64bytes))
1586         .int    JMPTBL (L(31bytes), L(table_64bytes))
1587         .int    JMPTBL (L(32bytes), L(table_64bytes))
1588         .int    JMPTBL (L(33bytes), L(table_64bytes))
1589         .int    JMPTBL (L(34bytes), L(table_64bytes))
1590         .int    JMPTBL (L(35bytes), L(table_64bytes))
1591         .int    JMPTBL (L(36bytes), L(table_64bytes))
1592         .int    JMPTBL (L(37bytes), L(table_64bytes))
1593         .int    JMPTBL (L(38bytes), L(table_64bytes))
1594         .int    JMPTBL (L(39bytes), L(table_64bytes))
1595         .int    JMPTBL (L(40bytes), L(table_64bytes))
1596         .int    JMPTBL (L(41bytes), L(table_64bytes))
1597         .int    JMPTBL (L(42bytes), L(table_64bytes))
1598         .int    JMPTBL (L(43bytes), L(table_64bytes))
1599         .int    JMPTBL (L(44bytes), L(table_64bytes))
1600         .int    JMPTBL (L(45bytes), L(table_64bytes))
1601         .int    JMPTBL (L(46bytes), L(table_64bytes))
1602         .int    JMPTBL (L(47bytes), L(table_64bytes))
1603         .int    JMPTBL (L(48bytes), L(table_64bytes))
1604         .int    JMPTBL (L(49bytes), L(table_64bytes))
1605         .int    JMPTBL (L(50bytes), L(table_64bytes))
1606         .int    JMPTBL (L(51bytes), L(table_64bytes))
1607         .int    JMPTBL (L(52bytes), L(table_64bytes))
1608         .int    JMPTBL (L(53bytes), L(table_64bytes))
1609         .int    JMPTBL (L(54bytes), L(table_64bytes))
1610         .int    JMPTBL (L(55bytes), L(table_64bytes))
1611         .int    JMPTBL (L(56bytes), L(table_64bytes))
1612         .int    JMPTBL (L(57bytes), L(table_64bytes))
1613         .int    JMPTBL (L(58bytes), L(table_64bytes))
1614         .int    JMPTBL (L(59bytes), L(table_64bytes))
1615         .int    JMPTBL (L(60bytes), L(table_64bytes))
1616         .int    JMPTBL (L(61bytes), L(table_64bytes))
1617         .int    JMPTBL (L(62bytes), L(table_64bytes))
1618         .int    JMPTBL (L(63bytes), L(table_64bytes))
1619         .int    JMPTBL (L(64bytes), L(table_64bytes))
1620         .int    JMPTBL (L(65bytes), L(table_64bytes))
1621         .int    JMPTBL (L(66bytes), L(table_64bytes))
1622         .int    JMPTBL (L(67bytes), L(table_64bytes))
1623         .int    JMPTBL (L(68bytes), L(table_64bytes))
1624         .int    JMPTBL (L(69bytes), L(table_64bytes))
1625         .int    JMPTBL (L(70bytes), L(table_64bytes))
1626         .int    JMPTBL (L(71bytes), L(table_64bytes))
1627         .int    JMPTBL (L(72bytes), L(table_64bytes))
1628         .int    JMPTBL (L(73bytes), L(table_64bytes))
1629         .int    JMPTBL (L(74bytes), L(table_64bytes))
1630         .int    JMPTBL (L(75bytes), L(table_64bytes))
1631         .int    JMPTBL (L(76bytes), L(table_64bytes))
1632         .int    JMPTBL (L(77bytes), L(table_64bytes))
1633         .int    JMPTBL (L(78bytes), L(table_64bytes))
1634         .int    JMPTBL (L(79bytes), L(table_64bytes))
1635 #endif