Import upstream 5.1.3.
[platform/upstream/gmp.git] / mpn / x86_64 / com.asm
1 dnl  AMD64 mpn_com.
2
3 dnl  Copyright 2004, 2005, 2006, 2011, 2012 Free Software Foundation, Inc.
4
5 dnl  This file is part of the GNU MP Library.
6
7 dnl  The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl  it under the terms of the GNU Lesser General Public License as published
9 dnl  by the Free Software Foundation; either version 3 of the License, or (at
10 dnl  your option) any later version.
11
12 dnl  The GNU MP Library is distributed in the hope that it will be useful, but
13 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15 dnl  License for more details.
16
17 dnl  You should have received a copy of the GNU Lesser General Public License
18 dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
19
20 include(`../config.m4')
21
22
23 C           cycles/limb
24 C AMD K8,K9      1.25
25 C AMD K10        1.25
26 C Intel P4       2.78
27 C Intel core2    1.1
28 C Intel corei    1.5
29 C Intel atom     ?
30 C VIA nano       2
31
32 C INPUT PARAMETERS
33 define(`rp',`%rdi')
34 define(`up',`%rsi')
35 define(`n',`%rdx')
36
37 ABI_SUPPORT(DOS64)
38 ABI_SUPPORT(STD64)
39
40 ASM_START()
41         TEXT
42         ALIGN(32)
43 PROLOGUE(mpn_com)
44         FUNC_ENTRY(3)
45         movq    (up), %r8
46         movl    R32(%rdx), R32(%rax)
47         leaq    (up,n,8), up
48         leaq    (rp,n,8), rp
49         negq    n
50         andl    $3, R32(%rax)
51         je      L(b00)
52         cmpl    $2, R32(%rax)
53         jc      L(b01)
54         je      L(b10)
55
56 L(b11): notq    %r8
57         movq    %r8, (rp,n,8)
58         decq    n
59         jmp     L(e11)
60 L(b10): addq    $-2, n
61         jmp     L(e10)
62         .byte   0x90,0x90,0x90,0x90,0x90,0x90
63 L(b01): notq    %r8
64         movq    %r8, (rp,n,8)
65         incq    n
66         jz      L(ret)
67
68 L(oop): movq    (up,n,8), %r8
69 L(b00): movq    8(up,n,8), %r9
70         notq    %r8
71         notq    %r9
72         movq    %r8, (rp,n,8)
73         movq    %r9, 8(rp,n,8)
74 L(e11): movq    16(up,n,8), %r8
75 L(e10): movq    24(up,n,8), %r9
76         notq    %r8
77         notq    %r9
78         movq    %r8, 16(rp,n,8)
79         movq    %r9, 24(rp,n,8)
80         addq    $4, n
81         jnc     L(oop)
82 L(ret): FUNC_EXIT()
83         ret
84 EPILOGUE()