xref: /titanic_51/usr/src/lib/libc/amd64/gen/memcmp.s (revision 9a70fc3be3b1e966bf78825cdb8d509963a6f0a1)
17c478bd9Sstevel@tonic-gate/*
27c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate */
57c478bd9Sstevel@tonic-gate
67c478bd9Sstevel@tonic-gate/*
77c478bd9Sstevel@tonic-gate * Copyright (c) 2002 Advanced Micro Devices, Inc.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * All rights reserved.
107c478bd9Sstevel@tonic-gate *
117c478bd9Sstevel@tonic-gate * Redistribution and  use in source and binary  forms, with or
127c478bd9Sstevel@tonic-gate * without  modification,  are   permitted  provided  that  the
137c478bd9Sstevel@tonic-gate * following conditions are met:
147c478bd9Sstevel@tonic-gate *
157c478bd9Sstevel@tonic-gate * + Redistributions  of source  code  must  retain  the  above
167c478bd9Sstevel@tonic-gate *   copyright  notice,   this  list  of   conditions  and  the
177c478bd9Sstevel@tonic-gate *   following disclaimer.
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * + Redistributions  in binary  form must reproduce  the above
207c478bd9Sstevel@tonic-gate *   copyright  notice,   this  list  of   conditions  and  the
217c478bd9Sstevel@tonic-gate *   following  disclaimer in  the  documentation and/or  other
227c478bd9Sstevel@tonic-gate *   materials provided with the distribution.
237c478bd9Sstevel@tonic-gate *
247c478bd9Sstevel@tonic-gate * + Neither the  name of Advanced Micro Devices,  Inc. nor the
257c478bd9Sstevel@tonic-gate *   names  of  its contributors  may  be  used  to endorse  or
267c478bd9Sstevel@tonic-gate *   promote  products  derived   from  this  software  without
277c478bd9Sstevel@tonic-gate *   specific prior written permission.
287c478bd9Sstevel@tonic-gate *
297c478bd9Sstevel@tonic-gate * THIS  SOFTWARE  IS PROVIDED  BY  THE  COPYRIGHT HOLDERS  AND
307c478bd9Sstevel@tonic-gate * CONTRIBUTORS AS IS AND  ANY EXPRESS OR IMPLIED WARRANTIES,
317c478bd9Sstevel@tonic-gate * INCLUDING,  BUT NOT  LIMITED TO,  THE IMPLIED  WARRANTIES OF
327c478bd9Sstevel@tonic-gate * MERCHANTABILITY  AND FITNESS  FOR A  PARTICULAR  PURPOSE ARE
337c478bd9Sstevel@tonic-gate * DISCLAIMED.  IN  NO  EVENT  SHALL  ADVANCED  MICRO  DEVICES,
347c478bd9Sstevel@tonic-gate * INC.  OR CONTRIBUTORS  BE LIABLE  FOR ANY  DIRECT, INDIRECT,
357c478bd9Sstevel@tonic-gate * INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR CONSEQUENTIAL  DAMAGES
367c478bd9Sstevel@tonic-gate * (INCLUDING,  BUT NOT LIMITED  TO, PROCUREMENT  OF SUBSTITUTE
377c478bd9Sstevel@tonic-gate * GOODS  OR  SERVICES;  LOSS  OF  USE, DATA,  OR  PROFITS;  OR
387c478bd9Sstevel@tonic-gate * BUSINESS INTERRUPTION)  HOWEVER CAUSED AND ON  ANY THEORY OF
397c478bd9Sstevel@tonic-gate * LIABILITY,  WHETHER IN CONTRACT,  STRICT LIABILITY,  OR TORT
407c478bd9Sstevel@tonic-gate * (INCLUDING NEGLIGENCE  OR OTHERWISE) ARISING IN  ANY WAY OUT
417c478bd9Sstevel@tonic-gate * OF THE  USE  OF  THIS  SOFTWARE, EVEN  IF  ADVISED  OF  THE
427c478bd9Sstevel@tonic-gate * POSSIBILITY OF SUCH DAMAGE.
437c478bd9Sstevel@tonic-gate *
447c478bd9Sstevel@tonic-gate * It is  licensee's responsibility  to comply with  any export
457c478bd9Sstevel@tonic-gate * regulations applicable in licensee's jurisdiction.
467c478bd9Sstevel@tonic-gate */
477c478bd9Sstevel@tonic-gate
48*9a70fc3bSMark J. Nelson	.file	"memcmp.s"
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate#include <sys/asm_linkage.h>
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate	ANSI_PRAGMA_WEAK(memcmp,function)
537c478bd9Sstevel@tonic-gate
547c478bd9Sstevel@tonic-gate#include "SYS.h"
557c478bd9Sstevel@tonic-gate#include "cache.h"
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gate#define LABEL(s) .memcmp/**/s
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate	ENTRY(memcmp)                 /* (const void *, const void*, size_t) */
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gateLABEL(try1):
627c478bd9Sstevel@tonic-gate        cmp     $8, %rdx
637c478bd9Sstevel@tonic-gate        jae     LABEL(1after)
647c478bd9Sstevel@tonic-gate
657c478bd9Sstevel@tonic-gateLABEL(1):                                /* 1-byte */
667c478bd9Sstevel@tonic-gate        test    %rdx, %rdx
677c478bd9Sstevel@tonic-gate        mov     $0, %eax
687c478bd9Sstevel@tonic-gate        jz      LABEL(exit)
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gateLABEL(1loop):
717c478bd9Sstevel@tonic-gate        movzbl  (%rdi), %eax
727c478bd9Sstevel@tonic-gate        movzbl  (%rsi), %ecx
737c478bd9Sstevel@tonic-gate        sub     %ecx, %eax
747c478bd9Sstevel@tonic-gate        jnz     LABEL(exit)
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate        dec     %rdx
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate        lea     1 (%rdi), %rdi
797c478bd9Sstevel@tonic-gate        lea     1 (%rsi), %rsi
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate        jnz     LABEL(1loop)
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gateLABEL(exit):
847c478bd9Sstevel@tonic-gate        rep
857c478bd9Sstevel@tonic-gate        ret
867c478bd9Sstevel@tonic-gate
877c478bd9Sstevel@tonic-gate        .p2align 4
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gateLABEL(1after):
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gateLABEL(8try):
927c478bd9Sstevel@tonic-gate        cmp     $32, %rdx
937c478bd9Sstevel@tonic-gate        jae     LABEL(8after)
947c478bd9Sstevel@tonic-gate
957c478bd9Sstevel@tonic-gateLABEL(8):                        /* 8-byte */
967c478bd9Sstevel@tonic-gate        mov     %edx, %ecx
977c478bd9Sstevel@tonic-gate        shr     $3, %ecx
987c478bd9Sstevel@tonic-gate        jz      LABEL(1)
997c478bd9Sstevel@tonic-gate
1007c478bd9Sstevel@tonic-gate        .p2align 4
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gateLABEL(8loop):
1037c478bd9Sstevel@tonic-gate        mov     (%rsi), %rax
1047c478bd9Sstevel@tonic-gate        cmp     (%rdi), %rax
1057c478bd9Sstevel@tonic-gate        jne     LABEL(1)
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate        sub     $8, %rdx
1087c478bd9Sstevel@tonic-gate        dec     %ecx
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gate        lea     8 (%rsi), %rsi
1117c478bd9Sstevel@tonic-gate        lea     8 (%rdi), %rdi
1127c478bd9Sstevel@tonic-gate
1137c478bd9Sstevel@tonic-gate        jnz     LABEL(8loop)
1147c478bd9Sstevel@tonic-gate
1157c478bd9Sstevel@tonic-gateLABEL(8skip):
1167c478bd9Sstevel@tonic-gate        and     $7, %edx
1177c478bd9Sstevel@tonic-gate        jnz     LABEL(1)
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gate        xor     %eax, %eax
1207c478bd9Sstevel@tonic-gate        ret
1217c478bd9Sstevel@tonic-gate
1227c478bd9Sstevel@tonic-gate        .p2align 4
1237c478bd9Sstevel@tonic-gate
1247c478bd9Sstevel@tonic-gateLABEL(8after):
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gateLABEL(32try):
1277c478bd9Sstevel@tonic-gate        cmp     $2048, %rdx
1287c478bd9Sstevel@tonic-gate        ja      LABEL(32after)
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gateLABEL(32):                               /* 32-byte */
1317c478bd9Sstevel@tonic-gate        mov     %edx, %ecx
1327c478bd9Sstevel@tonic-gate        shr     $5, %ecx
1337c478bd9Sstevel@tonic-gate        jz      LABEL(8)
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate        .p2align 4
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gateLABEL(32loop):
1387c478bd9Sstevel@tonic-gate        mov        (%rsi), %rax
1397c478bd9Sstevel@tonic-gate        mov      8 (%rsi),  %r8
1407c478bd9Sstevel@tonic-gate        mov     16 (%rsi),  %r9
1417c478bd9Sstevel@tonic-gate        mov     24 (%rsi), %r10
1427c478bd9Sstevel@tonic-gate        sub        (%rdi), %rax
1437c478bd9Sstevel@tonic-gate        sub      8 (%rdi),  %r8
1447c478bd9Sstevel@tonic-gate        sub     16 (%rdi),  %r9
1457c478bd9Sstevel@tonic-gate        sub     24 (%rdi), %r10
1467c478bd9Sstevel@tonic-gate
1477c478bd9Sstevel@tonic-gate        or      %rax,  %r8
1487c478bd9Sstevel@tonic-gate        or       %r9, %r10
1497c478bd9Sstevel@tonic-gate        or       %r8, %r10
1507c478bd9Sstevel@tonic-gate        jnz     LABEL(8)
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate        sub     $32, %rdx
1537c478bd9Sstevel@tonic-gate        dec     %ecx
1547c478bd9Sstevel@tonic-gate
1557c478bd9Sstevel@tonic-gate        lea     32 (%rsi), %rsi
1567c478bd9Sstevel@tonic-gate        lea     32 (%rdi), %rdi
1577c478bd9Sstevel@tonic-gate
1587c478bd9Sstevel@tonic-gate        jnz     LABEL(32loop)
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gateLABEL(32skip):
1617c478bd9Sstevel@tonic-gate        and     $31, %edx
1627c478bd9Sstevel@tonic-gate        jnz     LABEL(8)
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate        xor     %eax, %eax
1657c478bd9Sstevel@tonic-gate        ret
1667c478bd9Sstevel@tonic-gate
1677c478bd9Sstevel@tonic-gate        .p2align 4
1687c478bd9Sstevel@tonic-gate
1697c478bd9Sstevel@tonic-gateLABEL(32after):
1707c478bd9Sstevel@tonic-gate
1717c478bd9Sstevel@tonic-gate	prefetchnta _sref_(.amd64cache1half)	/* 3DNow: use prefetch */
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gateLABEL(srctry):
1747c478bd9Sstevel@tonic-gate        mov     %esi, %r8d      /* align by source */
1757c478bd9Sstevel@tonic-gate
1767c478bd9Sstevel@tonic-gate        and     $7, %r8d
1777c478bd9Sstevel@tonic-gate        jz      LABEL(srcafter)  /* not unaligned */
1787c478bd9Sstevel@tonic-gate
1797c478bd9Sstevel@tonic-gateLABEL(src):                      /* align */
1807c478bd9Sstevel@tonic-gate        lea     -8 (%r8, %rdx), %rdx
1817c478bd9Sstevel@tonic-gate        sub     $8, %r8d
1827c478bd9Sstevel@tonic-gate
1837c478bd9Sstevel@tonic-gate
1847c478bd9Sstevel@tonic-gateLABEL(srcloop):
1857c478bd9Sstevel@tonic-gate        movzbl  (%rdi), %eax
1867c478bd9Sstevel@tonic-gate        movzbl  (%rsi), %ecx
1877c478bd9Sstevel@tonic-gate        sub     %ecx, %eax
1887c478bd9Sstevel@tonic-gate        jnz     LABEL(exit)
1897c478bd9Sstevel@tonic-gate
1907c478bd9Sstevel@tonic-gate        inc     %r8d
1917c478bd9Sstevel@tonic-gate
1927c478bd9Sstevel@tonic-gate        lea     1 (%rdi), %rdi
1937c478bd9Sstevel@tonic-gate        lea     1 (%rsi), %rsi
1947c478bd9Sstevel@tonic-gate
1957c478bd9Sstevel@tonic-gate        jnz     LABEL(srcloop)
1967c478bd9Sstevel@tonic-gate
1977c478bd9Sstevel@tonic-gate        .p2align 4
1987c478bd9Sstevel@tonic-gate
1997c478bd9Sstevel@tonic-gateLABEL(srcafter):
2007c478bd9Sstevel@tonic-gate
2017c478bd9Sstevel@tonic-gateLABEL(64try):
2027c478bd9Sstevel@tonic-gate        mov     _sref_(.amd64cache1half), %rcx
2037c478bd9Sstevel@tonic-gate        cmp	%rdx, %rcx
2047c478bd9Sstevel@tonic-gate        cmova   %rdx, %rcx
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gateLABEL(64):                               /* 64-byte */
2077c478bd9Sstevel@tonic-gate        shr     $6, %rcx
2087c478bd9Sstevel@tonic-gate        jz      LABEL(32)
2097c478bd9Sstevel@tonic-gate
2107c478bd9Sstevel@tonic-gate        .p2align 4
2117c478bd9Sstevel@tonic-gate
2127c478bd9Sstevel@tonic-gateLABEL(64loop):
2137c478bd9Sstevel@tonic-gate        mov        (%rsi), %rax
2147c478bd9Sstevel@tonic-gate        mov      8 (%rsi),  %r8
2157c478bd9Sstevel@tonic-gate        sub        (%rdi), %rax
2167c478bd9Sstevel@tonic-gate        sub      8 (%rdi),  %r8
2177c478bd9Sstevel@tonic-gate        or      %r8,  %rax
2187c478bd9Sstevel@tonic-gate
2197c478bd9Sstevel@tonic-gate        mov     16 (%rsi),  %r9
2207c478bd9Sstevel@tonic-gate        mov     24 (%rsi), %r10
2217c478bd9Sstevel@tonic-gate        sub     16 (%rdi),  %r9
2227c478bd9Sstevel@tonic-gate        sub     24 (%rdi), %r10
2237c478bd9Sstevel@tonic-gate        or      %r10, %r9
2247c478bd9Sstevel@tonic-gate
2257c478bd9Sstevel@tonic-gate        or      %r9,  %rax
2267c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
2277c478bd9Sstevel@tonic-gate
2287c478bd9Sstevel@tonic-gate        mov     32 (%rsi), %rax
2297c478bd9Sstevel@tonic-gate        mov     40 (%rsi),  %r8
2307c478bd9Sstevel@tonic-gate        sub     32 (%rdi), %rax
2317c478bd9Sstevel@tonic-gate        sub     40 (%rdi),  %r8
2327c478bd9Sstevel@tonic-gate        or      %r8,  %rax
2337c478bd9Sstevel@tonic-gate
2347c478bd9Sstevel@tonic-gate        mov     48 (%rsi),  %r9
2357c478bd9Sstevel@tonic-gate        mov     56 (%rsi), %r10
2367c478bd9Sstevel@tonic-gate        sub     48 (%rdi),  %r9
2377c478bd9Sstevel@tonic-gate        sub     56 (%rdi), %r10
2387c478bd9Sstevel@tonic-gate        or      %r10, %r9
2397c478bd9Sstevel@tonic-gate
2407c478bd9Sstevel@tonic-gate        or      %r9,  %rax
2417c478bd9Sstevel@tonic-gate        jnz    	LABEL(32)
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate        lea     64 (%rsi), %rsi
2447c478bd9Sstevel@tonic-gate        lea     64 (%rdi), %rdi
2457c478bd9Sstevel@tonic-gate
2467c478bd9Sstevel@tonic-gate        sub     $64, %rdx
2477c478bd9Sstevel@tonic-gate        dec     %rcx
2487c478bd9Sstevel@tonic-gate        jnz     LABEL(64loop)
2497c478bd9Sstevel@tonic-gate
2507c478bd9Sstevel@tonic-gateLABEL(64skip):
2517c478bd9Sstevel@tonic-gate        cmp     $2048, %rdx
2527c478bd9Sstevel@tonic-gate        ja     LABEL(64after)
2537c478bd9Sstevel@tonic-gate
2547c478bd9Sstevel@tonic-gate        test    %edx, %edx
2557c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
2567c478bd9Sstevel@tonic-gate
2577c478bd9Sstevel@tonic-gate        xor     %eax, %eax
2587c478bd9Sstevel@tonic-gate        ret
2597c478bd9Sstevel@tonic-gate
2607c478bd9Sstevel@tonic-gate        .p2align 4
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gateLABEL(64after):
2637c478bd9Sstevel@tonic-gate
2647c478bd9Sstevel@tonic-gateLABEL(pretry):
2657c478bd9Sstevel@tonic-gate
2667c478bd9Sstevel@tonic-gateLABEL(pre):                              /* 64-byte prefetching */
2677c478bd9Sstevel@tonic-gate        mov     _sref_(.amd64cache2half), %rcx
2687c478bd9Sstevel@tonic-gate        cmp	%rdx, %rcx
2697c478bd9Sstevel@tonic-gate        cmova   %rdx, %rcx
2707c478bd9Sstevel@tonic-gate
2717c478bd9Sstevel@tonic-gate        shr     $6, %rcx
2727c478bd9Sstevel@tonic-gate        jz      LABEL(preskip)
2737c478bd9Sstevel@tonic-gate
2747c478bd9Sstevel@tonic-gate        prefetchnta 512 (%rsi)	/* 3DNow: use prefetch */
2757c478bd9Sstevel@tonic-gate        prefetchnta 512 (%rdi)	/* 3DNow: use prefetch */
2767c478bd9Sstevel@tonic-gate
2777c478bd9Sstevel@tonic-gate        mov        (%rsi), %rax
2787c478bd9Sstevel@tonic-gate        mov      8 (%rsi), %r9
2797c478bd9Sstevel@tonic-gate        mov     16 (%rsi), %r10
2807c478bd9Sstevel@tonic-gate        mov     24 (%rsi), %r11
2817c478bd9Sstevel@tonic-gate        sub        (%rdi), %rax
2827c478bd9Sstevel@tonic-gate        sub      8 (%rdi), %r9
2837c478bd9Sstevel@tonic-gate        sub     16 (%rdi), %r10
2847c478bd9Sstevel@tonic-gate        sub     24 (%rdi), %r11
2857c478bd9Sstevel@tonic-gate
2867c478bd9Sstevel@tonic-gate        or       %r9, %rax
2877c478bd9Sstevel@tonic-gate        or      %r11, %r10
2887c478bd9Sstevel@tonic-gate        or      %r10, %rax
2897c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
2907c478bd9Sstevel@tonic-gate
2917c478bd9Sstevel@tonic-gate        mov     32 (%rsi), %rax
2927c478bd9Sstevel@tonic-gate        mov     40 (%rsi), %r9
2937c478bd9Sstevel@tonic-gate        mov     48 (%rsi), %r10
2947c478bd9Sstevel@tonic-gate        mov     56 (%rsi), %r11
2957c478bd9Sstevel@tonic-gate        sub     32 (%rdi), %rax
2967c478bd9Sstevel@tonic-gate        sub     40 (%rdi), %r9
2977c478bd9Sstevel@tonic-gate        sub     48 (%rdi), %r10
2987c478bd9Sstevel@tonic-gate        sub     56 (%rdi), %r11
2997c478bd9Sstevel@tonic-gate
3007c478bd9Sstevel@tonic-gate        or       %r9, %rax
3017c478bd9Sstevel@tonic-gate        or      %r11, %r10
3027c478bd9Sstevel@tonic-gate        or      %r10, %rax
3037c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
3047c478bd9Sstevel@tonic-gate
3057c478bd9Sstevel@tonic-gate        lea     64 (%rsi), %rsi
3067c478bd9Sstevel@tonic-gate        lea     64 (%rdi), %rdi
3077c478bd9Sstevel@tonic-gate
3087c478bd9Sstevel@tonic-gate        sub     $64, %rdx
3097c478bd9Sstevel@tonic-gate        dec     %rcx
3107c478bd9Sstevel@tonic-gate
3117c478bd9Sstevel@tonic-gate        .p2align 4
3127c478bd9Sstevel@tonic-gate
3137c478bd9Sstevel@tonic-gateLABEL(preloop):
3147c478bd9Sstevel@tonic-gate        prefetchnta 512 (%rsi)	/* 3DNow: use prefetch */
3157c478bd9Sstevel@tonic-gate        prefetchnta 512 (%rdi)	/* 3DNow: use prefetch */
3167c478bd9Sstevel@tonic-gate
3177c478bd9Sstevel@tonic-gate        mov        (%rsi), %rax
3187c478bd9Sstevel@tonic-gate        mov      8 (%rsi), %r9
3197c478bd9Sstevel@tonic-gate        mov     16 (%rsi), %r10
3207c478bd9Sstevel@tonic-gate        mov     24 (%rsi), %r11
3217c478bd9Sstevel@tonic-gate        sub        (%rdi), %rax
3227c478bd9Sstevel@tonic-gate        sub      8 (%rdi), %r9
3237c478bd9Sstevel@tonic-gate        sub     16 (%rdi), %r10
3247c478bd9Sstevel@tonic-gate        sub     24 (%rdi), %r11
3257c478bd9Sstevel@tonic-gate
3267c478bd9Sstevel@tonic-gate        or       %r9, %rax
3277c478bd9Sstevel@tonic-gate        or      %r11, %r10
3287c478bd9Sstevel@tonic-gate        or      %r10, %rax
3297c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
3307c478bd9Sstevel@tonic-gate
3317c478bd9Sstevel@tonic-gate        mov     32 (%rsi), %rax
3327c478bd9Sstevel@tonic-gate        mov     40 (%rsi), %r9
3337c478bd9Sstevel@tonic-gate        mov     48 (%rsi), %r10
3347c478bd9Sstevel@tonic-gate        mov     56 (%rsi), %r11
3357c478bd9Sstevel@tonic-gate        sub     32 (%rdi), %rax
3367c478bd9Sstevel@tonic-gate        sub     40 (%rdi), %r9
3377c478bd9Sstevel@tonic-gate        sub     48 (%rdi), %r10
3387c478bd9Sstevel@tonic-gate        sub     56 (%rdi), %r11
3397c478bd9Sstevel@tonic-gate
3407c478bd9Sstevel@tonic-gate        or       %r9, %rax
3417c478bd9Sstevel@tonic-gate        or      %r11, %r10
3427c478bd9Sstevel@tonic-gate        or      %r10, %rax
3437c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
3447c478bd9Sstevel@tonic-gate
3457c478bd9Sstevel@tonic-gate        lea     64 (%rsi), %rsi
3467c478bd9Sstevel@tonic-gate        lea     64 (%rdi), %rdi
3477c478bd9Sstevel@tonic-gate
3487c478bd9Sstevel@tonic-gate        sub     $64, %rdx
3497c478bd9Sstevel@tonic-gate        dec     %rcx
3507c478bd9Sstevel@tonic-gate        jnz     LABEL(preloop)
3517c478bd9Sstevel@tonic-gate
3527c478bd9Sstevel@tonic-gate
3537c478bd9Sstevel@tonic-gateLABEL(preskip):
3547c478bd9Sstevel@tonic-gate        cmp     $2048, %rdx
3557c478bd9Sstevel@tonic-gate        ja      LABEL(preafter)
3567c478bd9Sstevel@tonic-gate
3577c478bd9Sstevel@tonic-gate        test    %edx, %edx
3587c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
3597c478bd9Sstevel@tonic-gate
3607c478bd9Sstevel@tonic-gate        xor     %eax, %eax
3617c478bd9Sstevel@tonic-gate        ret
3627c478bd9Sstevel@tonic-gate
3637c478bd9Sstevel@tonic-gate        .p2align 4
3647c478bd9Sstevel@tonic-gate
3657c478bd9Sstevel@tonic-gateLABEL(preafter):
3667c478bd9Sstevel@tonic-gate
3677c478bd9Sstevel@tonic-gateLABEL(128try):
3687c478bd9Sstevel@tonic-gate
3697c478bd9Sstevel@tonic-gateLABEL(128):                              /* 128-byte */
3707c478bd9Sstevel@tonic-gate        mov     %rdx, %rcx
3717c478bd9Sstevel@tonic-gate        shr     $7, %rcx
3727c478bd9Sstevel@tonic-gate        jz      LABEL(128skip)
3737c478bd9Sstevel@tonic-gate
3747c478bd9Sstevel@tonic-gate        .p2align 4
3757c478bd9Sstevel@tonic-gate
3767c478bd9Sstevel@tonic-gateLABEL(128loop):
3777c478bd9Sstevel@tonic-gate        prefetchnta 512 (%rsi)	/* 3DNow: use prefetch */
3787c478bd9Sstevel@tonic-gate        prefetchnta 512 (%rdi)	/* 3DNow: use prefetch */
3797c478bd9Sstevel@tonic-gate
3807c478bd9Sstevel@tonic-gate        mov        (%rsi), %rax
3817c478bd9Sstevel@tonic-gate        mov      8 (%rsi), %r8
3827c478bd9Sstevel@tonic-gate        sub        (%rdi), %rax
3837c478bd9Sstevel@tonic-gate        sub      8 (%rdi), %r8
3847c478bd9Sstevel@tonic-gate        mov     16 (%rsi), %r9
3857c478bd9Sstevel@tonic-gate        mov     24 (%rsi), %r10
3867c478bd9Sstevel@tonic-gate        sub     16 (%rdi), %r9
3877c478bd9Sstevel@tonic-gate        sub     24 (%rdi), %r10
3887c478bd9Sstevel@tonic-gate
3897c478bd9Sstevel@tonic-gate        or       %r8, %rax
3907c478bd9Sstevel@tonic-gate        or       %r9, %r10
3917c478bd9Sstevel@tonic-gate        or      %r10, %rax
3927c478bd9Sstevel@tonic-gate
3937c478bd9Sstevel@tonic-gate        mov     32 (%rsi), %r8
3947c478bd9Sstevel@tonic-gate        mov     40 (%rsi), %r9
3957c478bd9Sstevel@tonic-gate        sub     32 (%rdi), %r8
3967c478bd9Sstevel@tonic-gate        sub     40 (%rdi), %r9
3977c478bd9Sstevel@tonic-gate        mov     48 (%rsi), %r10
3987c478bd9Sstevel@tonic-gate        mov     56 (%rsi), %r11
3997c478bd9Sstevel@tonic-gate        sub     48 (%rdi), %r10
4007c478bd9Sstevel@tonic-gate        sub     56 (%rdi), %r11
4017c478bd9Sstevel@tonic-gate
4027c478bd9Sstevel@tonic-gate        or       %r9, %r8
4037c478bd9Sstevel@tonic-gate        or      %r11, %r10
4047c478bd9Sstevel@tonic-gate        or      %r10, %r8
4057c478bd9Sstevel@tonic-gate
4067c478bd9Sstevel@tonic-gate        or      %r8, %rax
4077c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
4087c478bd9Sstevel@tonic-gate
4097c478bd9Sstevel@tonic-gate        prefetchnta 576 (%rsi)	/* 3DNow: use prefetch */
4107c478bd9Sstevel@tonic-gate        prefetchnta 576 (%rdi)	/* 3DNow: use prefetch */
4117c478bd9Sstevel@tonic-gate
4127c478bd9Sstevel@tonic-gate        mov      64 (%rsi), %rax
4137c478bd9Sstevel@tonic-gate        mov      72 (%rsi), %r8
4147c478bd9Sstevel@tonic-gate        sub      64 (%rdi), %rax
4157c478bd9Sstevel@tonic-gate        sub      72 (%rdi), %r8
4167c478bd9Sstevel@tonic-gate        mov      80 (%rsi), %r9
4177c478bd9Sstevel@tonic-gate        mov      88 (%rsi), %r10
4187c478bd9Sstevel@tonic-gate        sub      80 (%rdi), %r9
4197c478bd9Sstevel@tonic-gate        sub      88 (%rdi), %r10
4207c478bd9Sstevel@tonic-gate
4217c478bd9Sstevel@tonic-gate        or       %r8, %rax
4227c478bd9Sstevel@tonic-gate        or       %r9, %r10
4237c478bd9Sstevel@tonic-gate        or      %r10, %rax
4247c478bd9Sstevel@tonic-gate
4257c478bd9Sstevel@tonic-gate        mov      96 (%rsi), %r8
4267c478bd9Sstevel@tonic-gate        mov     104 (%rsi), %r9
4277c478bd9Sstevel@tonic-gate        sub      96 (%rdi), %r8
4287c478bd9Sstevel@tonic-gate        sub     104 (%rdi), %r9
4297c478bd9Sstevel@tonic-gate        mov     112 (%rsi), %r10
4307c478bd9Sstevel@tonic-gate        mov     120 (%rsi), %r11
4317c478bd9Sstevel@tonic-gate        sub     112 (%rdi), %r10
4327c478bd9Sstevel@tonic-gate        sub     120 (%rdi), %r11
4337c478bd9Sstevel@tonic-gate
4347c478bd9Sstevel@tonic-gate        or       %r9, %r8
4357c478bd9Sstevel@tonic-gate        or      %r11, %r10
4367c478bd9Sstevel@tonic-gate        or      %r10, %r8
4377c478bd9Sstevel@tonic-gate
4387c478bd9Sstevel@tonic-gate        or      %r8, %rax
4397c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
4407c478bd9Sstevel@tonic-gate
4417c478bd9Sstevel@tonic-gate        sub     $128, %rdx
4427c478bd9Sstevel@tonic-gate        dec     %rcx
4437c478bd9Sstevel@tonic-gate
4447c478bd9Sstevel@tonic-gate        lea     128 (%rsi), %rsi
4457c478bd9Sstevel@tonic-gate        lea     128 (%rdi), %rdi
4467c478bd9Sstevel@tonic-gate
4477c478bd9Sstevel@tonic-gate        jnz     LABEL(128loop)
4487c478bd9Sstevel@tonic-gate
4497c478bd9Sstevel@tonic-gateLABEL(128skip):
4507c478bd9Sstevel@tonic-gate        and     $127, %edx
4517c478bd9Sstevel@tonic-gate        jnz     LABEL(32)
4527c478bd9Sstevel@tonic-gate
4537c478bd9Sstevel@tonic-gate        xor     %eax, %eax
4547c478bd9Sstevel@tonic-gate        ret
4557c478bd9Sstevel@tonic-gate
4567c478bd9Sstevel@tonic-gate	SET_SIZE(memcmp)
457