Imported Upstream version 5.0.5
[platform/upstream/gmp.git] / mpn / x86_64 / com.asm
1 dnl  AMD64 mpn_com.
2
3 dnl  Copyright 2004, 2005, 2006 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 K8,K9:        1.25
25 C K10:          1.25
26 C P4:           2.78
27 C P6-15:        1.1
28
29 C INPUT PARAMETERS
30 define(`rp',`%rdi')
31 define(`up',`%rsi')
32 define(`n',`%rdx')
33
34
35 ASM_START()
36         TEXT
37         ALIGN(32)
38 PROLOGUE(mpn_com)
39         movq    (up), %r8
40         movl    %edx, %eax
41         leaq    (up,n,8), up
42         leaq    (rp,n,8), rp
43         negq    n
44         andl    $3, %eax
45         je      L(b00)
46         cmpl    $2, %eax
47         jc      L(b01)
48         je      L(b10)
49
50 L(b11): notq    %r8
51         movq    %r8, (rp,n,8)
52         decq    n
53         jmp     L(e11)
54 L(b10): addq    $-2, n
55         jmp     L(e10)
56         .byte   0x90,0x90,0x90,0x90,0x90,0x90
57 L(b01): notq    %r8
58         movq    %r8, (rp,n,8)
59         incq    n
60         jz      L(ret)
61
62 L(oop): movq    (up,n,8), %r8
63 L(b00): movq    8(up,n,8), %r9
64         notq    %r8
65         notq    %r9
66         movq    %r8, (rp,n,8)
67         movq    %r9, 8(rp,n,8)
68 L(e11): movq    16(up,n,8), %r8
69 L(e10): movq    24(up,n,8), %r9
70         notq    %r8
71         notq    %r9
72         movq    %r8, 16(rp,n,8)
73         movq    %r9, 24(rp,n,8)
74         addq    $4, n
75         jnc     L(oop)
76 L(ret): ret
77 EPILOGUE()