Align x86 memcmp-sse4.S and fix unwind info.
[glibc.git] / sysdeps / i386 / i686 / multiarch / memcmp-sse4.S
blobb1ed778f1f358129c747caab51fd1dc219d4f1f1
1 /* memcmp with SSE4.2
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_2
28 #endif
30 #define CFI_PUSH(REG)                                           \
31   cfi_adjust_cfa_offset (4);                                    \
32   cfi_rel_offset (REG, 0)
34 #define CFI_POP(REG)                                            \
35   cfi_adjust_cfa_offset (-4);                                   \
36   cfi_restore (REG)
38 #define PUSH(REG)       pushl REG; CFI_PUSH (REG)
39 #define POP(REG)        popl REG; CFI_POP (REG)
41 #define PARMS           4
42 #define BLK1            PARMS
43 #define BLK2            BLK1+4
44 #define LEN             BLK2+4
45 #define RETURN          POP (%ebx); ret; CFI_PUSH (%ebx)
48 #ifdef SHARED
49 # define JMPTBL(I, B)   I - B
51 /* Load an entry in a jump table into EBX and branch to it.  TABLE is a
52    jump table with relative offsets.  INDEX is a register contains the
53    index into the jump table.   SCALE is the scale of INDEX. */
54 # define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)            \
55     /* We first load PC into EBX.  */                           \
56     call        __i686.get_pc_thunk.bx;                         \
57     /* Get the address of the jump table.  */                   \
58     addl        $(TABLE - .), %ebx;                             \
59     /* Get the entry and convert the relative offset to the     \
60        absolute address.  */                                    \
61     addl        (%ebx,INDEX,SCALE), %ebx;                       \
62     /* We loaded the jump table and adjuested EDX/ESI. Go.  */  \
63     jmp         *%ebx
65         .section        .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
66         .globl  __i686.get_pc_thunk.bx
67         .hidden __i686.get_pc_thunk.bx
68         ALIGN (4)
69         .type   __i686.get_pc_thunk.bx,@function
70 __i686.get_pc_thunk.bx:
71         movl    (%esp), %ebx
72         ret
73 #else
74 # define JMPTBL(I, B)   I
76 /* Load an entry in a jump table into EBX and branch to it.  TABLE is a
77    jump table with relative offsets.  INDEX is a register contains the
78    index into the jump table.   SCALE is the scale of INDEX. */
79 # define BRANCH_TO_JMPTBL_ENTRY(TABLE, INDEX, SCALE)            \
80     jmp         *TABLE(,INDEX,SCALE)
81 #endif
83         .section .text.sse4.2,"ax",@progbits
84 ENTRY (MEMCMP)
85         movl    BLK1(%esp), %eax
86         movl    BLK2(%esp), %edx
87         movl    LEN(%esp), %ecx
88         cmp     $1, %ecx
89         jbe     L(less1bytes)
90         pxor    %xmm0, %xmm0
91         cmp     $64, %ecx
92         ja      L(64bytesormore)
93         cmp     $8, %ecx
94         PUSH (%ebx)
95         jb      L(less8bytes)
96         add     %ecx, %edx
97         add     %ecx, %eax
98         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %ecx, 4)
100         ALIGN (4)
101 L(less8bytes):
102         mov     (%eax), %bl
103         cmpb    (%edx), %bl
104         jne     L(nonzero)
106         mov     1(%eax), %bl
107         cmpb    1(%edx), %bl
108         jne     L(nonzero)
110         cmp     $2, %ecx
111         jz      L(0bytes)
113         mov     2(%eax), %bl
114         cmpb    2(%edx), %bl
115         jne     L(nonzero)
117         cmp     $3, %ecx
118         jz      L(0bytes)
120         mov     3(%eax), %bl
121         cmpb    3(%edx), %bl
122         jne     L(nonzero)
124         cmp     $4, %ecx
125         jz      L(0bytes)
127         mov     4(%eax), %bl
128         cmpb    4(%edx), %bl
129         jne     L(nonzero)
131         cmp     $5, %ecx
132         jz      L(0bytes)
134         mov     5(%eax), %bl
135         cmpb    5(%edx), %bl
136         jne     L(nonzero)
138         cmp     $6, %ecx
139         jz      L(0bytes)
141         mov     6(%eax), %bl
142         cmpb    6(%edx), %bl
143         je      L(0bytes)
144 L(nonzero):
145         POP (%ebx)
146         mov     $1, %eax
147         ja      L(above)
148         neg     %eax
149 L(above):
150         ret
151         CFI_PUSH (%ebx)
153         ALIGN (4)
154 L(0bytes):
155         POP (%ebx)
156         xor     %eax, %eax
157         ret
159         ALIGN (4)
160 L(less1bytes):
161         jb      L(0bytesend)
162         movzbl  (%eax), %eax
163         movzbl  (%edx), %edx
164         sub     %edx, %eax
165         ret
167         ALIGN (4)
168 L(0bytesend):
169         xor     %eax, %eax
170         ret
172         ALIGN (4)
173 L(64bytesormore):
174         PUSH (%ebx)
175         mov     %ecx, %ebx
176         mov     $64, %ecx
177         sub     $64, %ebx
178 L(64bytesormore_loop):
179         movdqu  (%eax), %xmm1
180         movdqu  (%edx), %xmm2
181         pxor    %xmm1, %xmm2
182         ptest   %xmm2, %xmm0
183         jnc     L(find_16diff)
185         movdqu  16(%eax), %xmm1
186         movdqu  16(%edx), %xmm2
187         pxor    %xmm1, %xmm2
188         ptest   %xmm2, %xmm0
189         jnc     L(find_32diff)
191         movdqu  32(%eax), %xmm1
192         movdqu  32(%edx), %xmm2
193         pxor    %xmm1, %xmm2
194         ptest   %xmm2, %xmm0
195         jnc     L(find_48diff)
197         movdqu  48(%eax), %xmm1
198         movdqu  48(%edx), %xmm2
199         pxor    %xmm1, %xmm2
200         ptest   %xmm2, %xmm0
201         jnc     L(find_64diff)
202         add     %ecx, %eax
203         add     %ecx, %edx
204         sub     %ecx, %ebx
205         jae     L(64bytesormore_loop)
206         add     %ebx, %ecx
207         add     %ecx, %edx
208         add     %ecx, %eax
209         BRANCH_TO_JMPTBL_ENTRY(L(table_64bytes), %ecx, 4)
211         ALIGN (4)
212 L(find_16diff):
213         sub     $16, %ecx
214 L(find_32diff):
215         sub     $16, %ecx
216 L(find_48diff):
217         sub     $16, %ecx
218 L(find_64diff):
219         add     %ecx, %edx
220         add     %ecx, %eax
221         jmp     L(16bytes)
223         ALIGN (4)
224 L(16bytes):
225         mov     -16(%eax), %ecx
226         mov     -16(%edx), %ebx
227         cmp     %ebx, %ecx
228         jne     L(find_diff)
229 L(12bytes):
230         mov     -12(%eax), %ecx
231         mov     -12(%edx), %ebx
232         cmp     %ebx, %ecx
233         jne     L(find_diff)
234 L(8bytes):
235         mov     -8(%eax), %ecx
236         mov     -8(%edx), %ebx
237         cmp     %ebx, %ecx
238         jne     L(find_diff)
239 L(4bytes):
240         mov     -4(%eax), %ecx
241         mov     -4(%edx), %ebx
242         cmp     %ebx, %ecx
243         mov     $0, %eax
244         jne     L(find_diff)
245         RETURN
247         ALIGN (4)
248 L(49bytes):
249         movdqu  -49(%eax), %xmm1
250         movdqu  -49(%edx), %xmm2
251         mov     $-49, %ebx
252         pxor    %xmm1, %xmm2
253         ptest   %xmm2, %xmm0
254         jnc     L(less16bytes)
255 L(33bytes):
256         movdqu  -33(%eax), %xmm1
257         movdqu  -33(%edx), %xmm2
258         mov     $-33, %ebx
259         pxor    %xmm1, %xmm2
260         ptest   %xmm2, %xmm0
261         jnc     L(less16bytes)
262 L(17bytes):
263         mov     -17(%eax), %ecx
264         mov     -17(%edx), %ebx
265         cmp     %ebx, %ecx
266         jne     L(find_diff)
267 L(13bytes):
268         mov     -13(%eax), %ecx
269         mov     -13(%edx), %ebx
270         cmp     %ebx, %ecx
271         jne     L(find_diff)
272 L(9bytes):
273         mov     -9(%eax), %ecx
274         mov     -9(%edx), %ebx
275         cmp     %ebx, %ecx
276         jne     L(find_diff)
277 L(5bytes):
278         mov     -5(%eax), %ecx
279         mov     -5(%edx), %ebx
280         cmp     %ebx, %ecx
281         jne     L(find_diff)
282         movzbl  -1(%eax), %ecx
283         cmp     -1(%edx), %cl
284         mov     $0, %eax
285         jne     L(end)
286         RETURN
288         ALIGN (4)
289 L(50bytes):
290         mov     $-50, %ebx
291         movdqu  -50(%eax), %xmm1
292         movdqu  -50(%edx), %xmm2
293         pxor    %xmm1, %xmm2
294         ptest   %xmm2, %xmm0
295         jnc     L(less16bytes)
296 L(34bytes):
297         mov     $-34, %ebx
298         movdqu  -34(%eax), %xmm1
299         movdqu  -34(%edx), %xmm2
300         pxor    %xmm1, %xmm2
301         ptest   %xmm2, %xmm0
302         jnc     L(less16bytes)
303 L(18bytes):
304         mov     -18(%eax), %ecx
305         mov     -18(%edx), %ebx
306         cmp     %ebx, %ecx
307         jne     L(find_diff)
308 L(14bytes):
309         mov     -14(%eax), %ecx
310         mov     -14(%edx), %ebx
311         cmp     %ebx, %ecx
312         jne     L(find_diff)
313 L(10bytes):
314         mov     -10(%eax), %ecx
315         mov     -10(%edx), %ebx
316         cmp     %ebx, %ecx
317         jne     L(find_diff)
318 L(6bytes):
319         mov     -6(%eax), %ecx
320         mov     -6(%edx), %ebx
321         cmp     %ebx, %ecx
322         jne     L(find_diff)
323 L(2bytes):
324         movzwl  -2(%eax), %ecx
325         movzwl  -2(%edx), %ebx
326         cmp     %bl, %cl
327         jne     L(end)
328         cmp     %bh, %ch
329         mov     $0, %eax
330         jne     L(end)
331         RETURN
333         ALIGN (4)
334 L(51bytes):
335         mov     $-51, %ebx
336         movdqu  -51(%eax), %xmm1
337         movdqu  -51(%edx), %xmm2
338         pxor    %xmm1, %xmm2
339         ptest   %xmm2, %xmm0
340         jnc     L(less16bytes)
341 L(35bytes):
342         mov     $-35, %ebx
343         movdqu  -35(%eax), %xmm1
344         movdqu  -35(%edx), %xmm2
345         pxor    %xmm1, %xmm2
346         ptest   %xmm2, %xmm0
347         jnc     L(less16bytes)
348 L(19bytes):
349         movl    -19(%eax), %ecx
350         movl    -19(%edx), %ebx
351         cmp     %ebx, %ecx
352         jne     L(find_diff)
353 L(15bytes):
354         movl    -15(%eax), %ecx
355         movl    -15(%edx), %ebx
356         cmp     %ebx, %ecx
357         jne     L(find_diff)
358 L(11bytes):
359         movl    -11(%eax), %ecx
360         movl    -11(%edx), %ebx
361         cmp     %ebx, %ecx
362         jne     L(find_diff)
363 L(7bytes):
364         movl    -7(%eax), %ecx
365         movl    -7(%edx), %ebx
366         cmp     %ebx, %ecx
367         jne     L(find_diff)
368 L(3bytes):
369         movzwl  -3(%eax), %ecx
370         movzwl  -3(%edx), %ebx
371         cmpb    %bl, %cl
372         jne     L(end)
373         cmp     %bx, %cx
374         jne     L(end)
375 L(1bytes):
376         movzbl  -1(%eax), %eax
377         cmpb    -1(%edx), %al
378         mov     $0, %eax
379         jne     L(end)
380         RETURN
382         ALIGN (4)
383 L(52bytes):
384         movdqu  -52(%eax), %xmm1
385         movdqu  -52(%edx), %xmm2
386         mov     $-52, %ebx
387         pxor    %xmm1, %xmm2
388         ptest   %xmm2, %xmm0
389         jnc     L(less16bytes)
390 L(36bytes):
391         movdqu  -36(%eax), %xmm1
392         movdqu  -36(%edx), %xmm2
393         mov     $-36, %ebx
394         pxor    %xmm1, %xmm2
395         ptest   %xmm2, %xmm0
396         jnc     L(less16bytes)
397 L(20bytes):
398         movdqu  -20(%eax), %xmm1
399         movdqu  -20(%edx), %xmm2
400         mov     $-20, %ebx
401         pxor    %xmm1, %xmm2
402         ptest   %xmm2, %xmm0
403         jnc     L(less16bytes)
404         mov     -4(%eax), %ecx
405         mov     -4(%edx), %ebx
406         cmp     %ebx, %ecx
407         mov     $0, %eax
408         jne     L(find_diff)
409         RETURN
411         ALIGN (4)
412 L(53bytes):
413         movdqu  -53(%eax), %xmm1
414         movdqu  -53(%edx), %xmm2
415         mov     $-53, %ebx
416         pxor    %xmm1, %xmm2
417         ptest   %xmm2, %xmm0
418         jnc     L(less16bytes)
419 L(37bytes):
420         mov     $-37, %ebx
421         movdqu  -37(%eax), %xmm1
422         movdqu  -37(%edx), %xmm2
423         pxor    %xmm1, %xmm2
424         ptest   %xmm2, %xmm0
425         jnc     L(less16bytes)
426 L(21bytes):
427         mov     $-21, %ebx
428         movdqu  -21(%eax), %xmm1
429         movdqu  -21(%edx), %xmm2
430         pxor    %xmm1, %xmm2
431         ptest   %xmm2, %xmm0
432         jnc     L(less16bytes)
433         mov     -5(%eax), %ecx
434         mov     -5(%edx), %ebx
435         cmp     %ebx, %ecx
436         jne     L(find_diff)
437         movzbl  -1(%eax), %ecx
438         cmp     -1(%edx), %cl
439         mov     $0, %eax
440         jne     L(end)
441         RETURN
443         ALIGN (4)
444 L(54bytes):
445         movdqu  -54(%eax), %xmm1
446         movdqu  -54(%edx), %xmm2
447         mov     $-54, %ebx
448         pxor    %xmm1, %xmm2
449         ptest   %xmm2, %xmm0
450         jnc     L(less16bytes)
451 L(38bytes):
452         mov     $-38, %ebx
453         movdqu  -38(%eax), %xmm1
454         movdqu  -38(%edx), %xmm2
455         pxor    %xmm1, %xmm2
456         ptest   %xmm2, %xmm0
457         jnc     L(less16bytes)
458 L(22bytes):
459         mov     $-22, %ebx
460         movdqu  -22(%eax), %xmm1
461         movdqu  -22(%edx), %xmm2
462         pxor    %xmm1, %xmm2
463         ptest   %xmm2, %xmm0
464         jnc     L(less16bytes)
466         mov     -6(%eax), %ecx
467         mov     -6(%edx), %ebx
468         cmp     %ebx, %ecx
469         jne     L(find_diff)
470         movzwl  -2(%eax), %ecx
471         movzwl  -2(%edx), %ebx
472         cmp     %bl, %cl
473         jne     L(end)
474         cmp     %bh, %ch
475         mov     $0, %eax
476         jne     L(end)
477         RETURN
479         ALIGN (4)
480 L(55bytes):
481         movdqu  -55(%eax), %xmm1
482         movdqu  -55(%edx), %xmm2
483         mov     $-55, %ebx
484         pxor    %xmm1, %xmm2
485         ptest   %xmm2, %xmm0
486         jnc     L(less16bytes)
487 L(39bytes):
488         mov     $-39, %ebx
489         movdqu  -39(%eax), %xmm1
490         movdqu  -39(%edx), %xmm2
491         pxor    %xmm1, %xmm2
492         ptest   %xmm2, %xmm0
493         jnc     L(less16bytes)
494 L(23bytes):
495         mov     $-23, %ebx
496         movdqu  -23(%eax), %xmm1
497         movdqu  -23(%edx), %xmm2
498         pxor    %xmm1, %xmm2
499         ptest   %xmm2, %xmm0
500         jnc     L(less16bytes)
501         movl    -7(%eax), %ecx
502         movl    -7(%edx), %ebx
503         cmp     %ebx, %ecx
504         jne     L(find_diff)
505         movzwl  -3(%eax), %ecx
506         movzwl  -3(%edx), %ebx
507         cmpb    %bl, %cl
508         jne     L(end)
509         cmp     %bx, %cx
510         jne     L(end)
511         movzbl  -1(%eax), %eax
512         cmpb    -1(%edx), %al
513         mov     $0, %eax
514         jne     L(end)
515         RETURN
517         ALIGN (4)
518 L(56bytes):
519         movdqu  -56(%eax), %xmm1
520         movdqu  -56(%edx), %xmm2
521         mov     $-56, %ebx
522         pxor    %xmm1, %xmm2
523         ptest   %xmm2, %xmm0
524         jnc     L(less16bytes)
525 L(40bytes):
526         mov     $-40, %ebx
527         movdqu  -40(%eax), %xmm1
528         movdqu  -40(%edx), %xmm2
529         pxor    %xmm1, %xmm2
530         ptest   %xmm2, %xmm0
531         jnc     L(less16bytes)
532 L(24bytes):
533         mov     $-24, %ebx
534         movdqu  -24(%eax), %xmm1
535         movdqu  -24(%edx), %xmm2
536         pxor    %xmm1, %xmm2
537         ptest   %xmm2, %xmm0
538         jnc     L(less16bytes)
540         mov     -8(%eax), %ecx
541         mov     -8(%edx), %ebx
542         cmp     %ebx, %ecx
543         jne     L(find_diff)
545         mov     -4(%eax), %ecx
546         mov     -4(%edx), %ebx
547         cmp     %ebx, %ecx
548         mov     $0, %eax
549         jne     L(find_diff)
550         RETURN
552         ALIGN (4)
553 L(57bytes):
554         movdqu  -57(%eax), %xmm1
555         movdqu  -57(%edx), %xmm2
556         mov     $-57, %ebx
557         pxor    %xmm1, %xmm2
558         ptest   %xmm2, %xmm0
559         jnc     L(less16bytes)
560 L(41bytes):
561         mov     $-41, %ebx
562         movdqu  -41(%eax), %xmm1
563         movdqu  -41(%edx), %xmm2
564         pxor    %xmm1, %xmm2
565         ptest   %xmm2, %xmm0
566         jnc     L(less16bytes)
567 L(25bytes):
568         mov     $-25, %ebx
569         movdqu  -25(%eax), %xmm1
570         movdqu  -25(%edx), %xmm2
571         pxor    %xmm1, %xmm2
572         ptest   %xmm2, %xmm0
573         jnc     L(less16bytes)
574         mov     -9(%eax), %ecx
575         mov     -9(%edx), %ebx
576         cmp     %ebx, %ecx
577         jne     L(find_diff)
578         mov     -5(%eax), %ecx
579         mov     -5(%edx), %ebx
580         cmp     %ebx, %ecx
581         jne     L(find_diff)
582         movzbl  -1(%eax), %ecx
583         cmp     -1(%edx), %cl
584         mov     $0, %eax
585         jne     L(end)
586         RETURN
588         ALIGN (4)
589 L(58bytes):
590         movdqu  -58(%eax), %xmm1
591         movdqu  -58(%edx), %xmm2
592         mov     $-58, %ebx
593         pxor    %xmm1, %xmm2
594         ptest   %xmm2, %xmm0
595         jnc     L(less16bytes)
596 L(42bytes):
597         mov     $-42, %ebx
598         movdqu  -42(%eax), %xmm1
599         movdqu  -42(%edx), %xmm2
600         pxor    %xmm1, %xmm2
601         ptest   %xmm2, %xmm0
602         jnc     L(less16bytes)
603 L(26bytes):
604         mov     $-26, %ebx
605         movdqu  -26(%eax), %xmm1
606         movdqu  -26(%edx), %xmm2
607         pxor    %xmm1, %xmm2
608         ptest   %xmm2, %xmm0
609         jnc     L(less16bytes)
611         mov     -10(%eax), %ecx
612         mov     -10(%edx), %ebx
613         cmp     %ebx, %ecx
614         jne     L(find_diff)
616         mov     -6(%eax), %ecx
617         mov     -6(%edx), %ebx
618         cmp     %ebx, %ecx
619         jne     L(find_diff)
621         movzwl  -2(%eax), %ecx
622         movzwl  -2(%edx), %ebx
623         cmp     %bl, %cl
624         jne     L(end)
625         cmp     %bh, %ch
626         mov     $0, %eax
627         jne     L(end)
628         RETURN
630         ALIGN (4)
631 L(59bytes):
632         movdqu  -59(%eax), %xmm1
633         movdqu  -59(%edx), %xmm2
634         mov     $-59, %ebx
635         pxor    %xmm1, %xmm2
636         ptest   %xmm2, %xmm0
637         jnc     L(less16bytes)
638 L(43bytes):
639         mov     $-43, %ebx
640         movdqu  -43(%eax), %xmm1
641         movdqu  -43(%edx), %xmm2
642         pxor    %xmm1, %xmm2
643         ptest   %xmm2, %xmm0
644         jnc     L(less16bytes)
645 L(27bytes):
646         mov     $-27, %ebx
647         movdqu  -27(%eax), %xmm1
648         movdqu  -27(%edx), %xmm2
649         pxor    %xmm1, %xmm2
650         ptest   %xmm2, %xmm0
651         jnc     L(less16bytes)
652         movl    -11(%eax), %ecx
653         movl    -11(%edx), %ebx
654         cmp     %ebx, %ecx
655         jne     L(find_diff)
656         movl    -7(%eax), %ecx
657         movl    -7(%edx), %ebx
658         cmp     %ebx, %ecx
659         jne     L(find_diff)
660         movzwl  -3(%eax), %ecx
661         movzwl  -3(%edx), %ebx
662         cmpb    %bl, %cl
663         jne     L(end)
664         cmp     %bx, %cx
665         jne     L(end)
666         movzbl  -1(%eax), %eax
667         cmpb    -1(%edx), %al
668         mov     $0, %eax
669         jne     L(end)
670         RETURN
672         ALIGN (4)
673 L(60bytes):
674         movdqu  -60(%eax), %xmm1
675         movdqu  -60(%edx), %xmm2
676         mov     $-60, %ebx
677         pxor    %xmm1, %xmm2
678         ptest   %xmm2, %xmm0
679         jnc     L(less16bytes)
680 L(44bytes):
681         mov     $-44, %ebx
682         movdqu  -44(%eax), %xmm1
683         movdqu  -44(%edx), %xmm2
684         pxor    %xmm1, %xmm2
685         ptest   %xmm2, %xmm0
686         jnc     L(less16bytes)
687 L(28bytes):
688         mov     $-28, %ebx
689         movdqu  -28(%eax), %xmm1
690         movdqu  -28(%edx), %xmm2
691         pxor    %xmm1, %xmm2
692         ptest   %xmm2, %xmm0
693         jnc     L(less16bytes)
694         mov     -12(%eax), %ecx
695         mov     -12(%edx), %ebx
696         cmp     %ebx, %ecx
697         jne     L(find_diff)
698         mov     -8(%eax), %ecx
699         mov     -8(%edx), %ebx
700         cmp     %ebx, %ecx
701         jne     L(find_diff)
702         mov     -4(%eax), %ecx
703         mov     -4(%edx), %ebx
704         cmp     %ebx, %ecx
705         mov     $0, %eax
706         jne     L(find_diff)
707         RETURN
709         ALIGN (4)
710 L(61bytes):
711         movdqu  -61(%eax), %xmm1
712         movdqu  -61(%edx), %xmm2
713         mov     $-61, %ebx
714         pxor    %xmm1, %xmm2
715         ptest   %xmm2, %xmm0
716         jnc     L(less16bytes)
717 L(45bytes):
718         mov     $-45, %ebx
719         movdqu  -45(%eax), %xmm1
720         movdqu  -45(%edx), %xmm2
721         pxor    %xmm1, %xmm2
722         ptest   %xmm2, %xmm0
723         jnc     L(less16bytes)
724 L(29bytes):
725         mov     $-29, %ebx
726         movdqu  -29(%eax), %xmm1
727         movdqu  -29(%edx), %xmm2
728         pxor    %xmm1, %xmm2
729         ptest   %xmm2, %xmm0
730         jnc     L(less16bytes)
732         mov     -13(%eax), %ecx
733         mov     -13(%edx), %ebx
734         cmp     %ebx, %ecx
735         jne     L(find_diff)
737         mov     -9(%eax), %ecx
738         mov     -9(%edx), %ebx
739         cmp     %ebx, %ecx
740         jne     L(find_diff)
742         mov     -5(%eax), %ecx
743         mov     -5(%edx), %ebx
744         cmp     %ebx, %ecx
745         jne     L(find_diff)
746         movzbl  -1(%eax), %ecx
747         cmp     -1(%edx), %cl
748         mov     $0, %eax
749         jne     L(end)
750         RETURN
752         ALIGN (4)
753 L(62bytes):
754         movdqu  -62(%eax), %xmm1
755         movdqu  -62(%edx), %xmm2
756         mov     $-62, %ebx
757         pxor    %xmm1, %xmm2
758         ptest   %xmm2, %xmm0
759         jnc     L(less16bytes)
760 L(46bytes):
761         mov     $-46, %ebx
762         movdqu  -46(%eax), %xmm1
763         movdqu  -46(%edx), %xmm2
764         pxor    %xmm1, %xmm2
765         ptest   %xmm2, %xmm0
766         jnc     L(less16bytes)
767 L(30bytes):
768         mov     $-30, %ebx
769         movdqu  -30(%eax), %xmm1
770         movdqu  -30(%edx), %xmm2
771         pxor    %xmm1, %xmm2
772         ptest   %xmm2, %xmm0
773         jnc     L(less16bytes)
774         mov     -14(%eax), %ecx
775         mov     -14(%edx), %ebx
776         cmp     %ebx, %ecx
777         jne     L(find_diff)
778         mov     -10(%eax), %ecx
779         mov     -10(%edx), %ebx
780         cmp     %ebx, %ecx
781         jne     L(find_diff)
782         mov     -6(%eax), %ecx
783         mov     -6(%edx), %ebx
784         cmp     %ebx, %ecx
785         jne     L(find_diff)
786         movzwl  -2(%eax), %ecx
787         movzwl  -2(%edx), %ebx
788         cmp     %bl, %cl
789         jne     L(end)
790         cmp     %bh, %ch
791         mov     $0, %eax
792         jne     L(end)
793         RETURN
795         ALIGN (4)
796 L(63bytes):
797         movdqu  -63(%eax), %xmm1
798         movdqu  -63(%edx), %xmm2
799         mov     $-63, %ebx
800         pxor    %xmm1, %xmm2
801         ptest   %xmm2, %xmm0
802         jnc     L(less16bytes)
803 L(47bytes):
804         mov     $-47, %ebx
805         movdqu  -47(%eax), %xmm1
806         movdqu  -47(%edx), %xmm2
807         pxor    %xmm1, %xmm2
808         ptest   %xmm2, %xmm0
809         jnc     L(less16bytes)
810 L(31bytes):
811         mov     $-31, %ebx
812         movdqu  -31(%eax), %xmm1
813         movdqu  -31(%edx), %xmm2
814         pxor    %xmm1, %xmm2
815         ptest   %xmm2, %xmm0
816         jnc     L(less16bytes)
818         movl    -15(%eax), %ecx
819         movl    -15(%edx), %ebx
820         cmp     %ebx, %ecx
821         jne     L(find_diff)
822         movl    -11(%eax), %ecx
823         movl    -11(%edx), %ebx
824         cmp     %ebx, %ecx
825         jne     L(find_diff)
826         movl    -7(%eax), %ecx
827         movl    -7(%edx), %ebx
828         cmp     %ebx, %ecx
829         jne     L(find_diff)
830         movzwl  -3(%eax), %ecx
831         movzwl  -3(%edx), %ebx
832         cmpb    %bl, %cl
833         jne     L(end)
834         cmp     %bx, %cx
835         jne     L(end)
836         movzbl  -1(%eax), %eax
837         cmpb    -1(%edx), %al
838         mov     $0, %eax
839         jne     L(end)
840         RETURN
842         ALIGN (4)
843 L(64bytes):
844         movdqu  -64(%eax), %xmm1
845         movdqu  -64(%edx), %xmm2
846         mov     $-64, %ebx
847         pxor    %xmm1, %xmm2
848         ptest   %xmm2, %xmm0
849         jnc     L(less16bytes)
850 L(48bytes):
851         movdqu  -48(%eax), %xmm1
852         movdqu  -48(%edx), %xmm2
853         mov     $-48, %ebx
854         pxor    %xmm1, %xmm2
855         ptest   %xmm2, %xmm0
856         jnc     L(less16bytes)
857 L(32bytes):
858         movdqu  -32(%eax), %xmm1
859         movdqu  -32(%edx), %xmm2
860         mov     $-32, %ebx
861         pxor    %xmm1, %xmm2
862         ptest   %xmm2, %xmm0
863         jnc     L(less16bytes)
865         mov     -16(%eax), %ecx
866         mov     -16(%edx), %ebx
867         cmp     %ebx, %ecx
868         jne     L(find_diff)
870         mov     -12(%eax), %ecx
871         mov     -12(%edx), %ebx
872         cmp     %ebx, %ecx
873         jne     L(find_diff)
875         mov     -8(%eax), %ecx
876         mov     -8(%edx), %ebx
877         cmp     %ebx, %ecx
878         jne     L(find_diff)
880         mov     -4(%eax), %ecx
881         mov     -4(%edx), %ebx
882         cmp     %ebx, %ecx
883         mov     $0, %eax
884         jne     L(find_diff)
885         RETURN
887         ALIGN (4)
888 L(less16bytes):
889         add     %ebx, %eax
890         add     %ebx, %edx
892         mov     (%eax), %ecx
893         mov     (%edx), %ebx
894         cmp     %ebx, %ecx
895         jne     L(find_diff)
897         mov     4(%eax), %ecx
898         mov     4(%edx), %ebx
899         cmp     %ebx, %ecx
900         jne     L(find_diff)
902         mov     8(%eax), %ecx
903         mov     8(%edx), %ebx
904         cmp     %ebx, %ecx
905         jne     L(find_diff)
907         mov     12(%eax), %ecx
908         mov     12(%edx), %ebx
909         cmp     %ebx, %ecx
910         mov     $0, %eax
911         jne     L(find_diff)
912         RETURN
914         ALIGN (4)
915 L(find_diff):
916         cmpb    %bl, %cl
917         jne     L(end)
918         cmp     %bx, %cx
919         jne     L(end)
920         shr     $16,%ecx
921         shr     $16,%ebx
922         cmp     %bl, %cl
923         jne     L(end)
924         cmp     %bx, %cx
925 L(end):
926         POP (%ebx)
927         mov     $1, %eax
928         ja      L(bigger)
929         neg     %eax
930 L(bigger):
931         ret
932 END (MEMCMP)
934         .section .rodata.sse4.2,"a",@progbits
935         ALIGN (2)
936         .type   L(table_64bytes), @object
937 L(table_64bytes):
938         .int    JMPTBL (L(0bytes), L(table_64bytes))
939         .int    JMPTBL (L(1bytes), L(table_64bytes))
940         .int    JMPTBL (L(2bytes), L(table_64bytes))
941         .int    JMPTBL (L(3bytes), L(table_64bytes))
942         .int    JMPTBL (L(4bytes), L(table_64bytes))
943         .int    JMPTBL (L(5bytes), L(table_64bytes))
944         .int    JMPTBL (L(6bytes), L(table_64bytes))
945         .int    JMPTBL (L(7bytes), L(table_64bytes))
946         .int    JMPTBL (L(8bytes), L(table_64bytes))
947         .int    JMPTBL (L(9bytes), L(table_64bytes))
948         .int    JMPTBL (L(10bytes), L(table_64bytes))
949         .int    JMPTBL (L(11bytes), L(table_64bytes))
950         .int    JMPTBL (L(12bytes), L(table_64bytes))
951         .int    JMPTBL (L(13bytes), L(table_64bytes))
952         .int    JMPTBL (L(14bytes), L(table_64bytes))
953         .int    JMPTBL (L(15bytes), L(table_64bytes))
954         .int    JMPTBL (L(16bytes), L(table_64bytes))
955         .int    JMPTBL (L(17bytes), L(table_64bytes))
956         .int    JMPTBL (L(18bytes), L(table_64bytes))
957         .int    JMPTBL (L(19bytes), L(table_64bytes))
958         .int    JMPTBL (L(20bytes), L(table_64bytes))
959         .int    JMPTBL (L(21bytes), L(table_64bytes))
960         .int    JMPTBL (L(22bytes), L(table_64bytes))
961         .int    JMPTBL (L(23bytes), L(table_64bytes))
962         .int    JMPTBL (L(24bytes), L(table_64bytes))
963         .int    JMPTBL (L(25bytes), L(table_64bytes))
964         .int    JMPTBL (L(26bytes), L(table_64bytes))
965         .int    JMPTBL (L(27bytes), L(table_64bytes))
966         .int    JMPTBL (L(28bytes), L(table_64bytes))
967         .int    JMPTBL (L(29bytes), L(table_64bytes))
968         .int    JMPTBL (L(30bytes), L(table_64bytes))
969         .int    JMPTBL (L(31bytes), L(table_64bytes))
970         .int    JMPTBL (L(32bytes), L(table_64bytes))
971         .int    JMPTBL (L(33bytes), L(table_64bytes))
972         .int    JMPTBL (L(34bytes), L(table_64bytes))
973         .int    JMPTBL (L(35bytes), L(table_64bytes))
974         .int    JMPTBL (L(36bytes), L(table_64bytes))
975         .int    JMPTBL (L(37bytes), L(table_64bytes))
976         .int    JMPTBL (L(38bytes), L(table_64bytes))
977         .int    JMPTBL (L(39bytes), L(table_64bytes))
978         .int    JMPTBL (L(40bytes), L(table_64bytes))
979         .int    JMPTBL (L(41bytes), L(table_64bytes))
980         .int    JMPTBL (L(42bytes), L(table_64bytes))
981         .int    JMPTBL (L(43bytes), L(table_64bytes))
982         .int    JMPTBL (L(44bytes), L(table_64bytes))
983         .int    JMPTBL (L(45bytes), L(table_64bytes))
984         .int    JMPTBL (L(46bytes), L(table_64bytes))
985         .int    JMPTBL (L(47bytes), L(table_64bytes))
986         .int    JMPTBL (L(48bytes), L(table_64bytes))
987         .int    JMPTBL (L(49bytes), L(table_64bytes))
988         .int    JMPTBL (L(50bytes), L(table_64bytes))
989         .int    JMPTBL (L(51bytes), L(table_64bytes))
990         .int    JMPTBL (L(52bytes), L(table_64bytes))
991         .int    JMPTBL (L(53bytes), L(table_64bytes))
992         .int    JMPTBL (L(54bytes), L(table_64bytes))
993         .int    JMPTBL (L(55bytes), L(table_64bytes))
994         .int    JMPTBL (L(56bytes), L(table_64bytes))
995         .int    JMPTBL (L(57bytes), L(table_64bytes))
996         .int    JMPTBL (L(58bytes), L(table_64bytes))
997         .int    JMPTBL (L(59bytes), L(table_64bytes))
998         .int    JMPTBL (L(60bytes), L(table_64bytes))
999         .int    JMPTBL (L(61bytes), L(table_64bytes))
1000         .int    JMPTBL (L(62bytes), L(table_64bytes))
1001         .int    JMPTBL (L(63bytes), L(table_64bytes))
1002         .int    JMPTBL (L(64bytes), L(table_64bytes))
1003         .size   L(table_64bytes), .-L(table_64bytes)
1004 #endif