Tizen 2.1 base
[external/gmp.git] / mpn / x86_64 / bdiv_dbm1c.asm
1 dnl  x86_64 mpn_bdiv_dbm1.
2
3 dnl  Copyright 2008 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 C            cycles/limb
23 C K8,K9:         2.25
24 C K10:            ?
25 C P4:           12.5
26 C P6 core2:      4.0
27 C P6 corei7:     3.8
28 C P6 atom:      20
29
30 C TODO
31 C  * Do proper 4-way feed-in instead of the current epilogue
32
33 C INPUT PARAMETERS shared
34 define(`qp',    `%rdi')
35 define(`up',    `%rsi')
36 define(`n',     `%rdx')
37 define(`bd',    `%rcx')
38 define(`cy',    `%r8')
39
40
41 ASM_START()
42         TEXT
43         ALIGN(16)
44 PROLOGUE(mpn_bdiv_dbm1c)
45         mov     (%rsi), %rax
46         mov     %rdx, %r9               C n
47
48         mul     %rcx
49         sub     %rax, %r8
50         mov     %r8, (%rdi)
51         sbb     %rdx, %r8
52
53         lea     (%rsi,%r9,8), %rsi
54         lea     (%rdi,%r9,8), %rdi
55         neg     %r9
56         add     $4, %r9
57         jns     L(end)
58         ALIGN(16)
59 L(top):
60         mov     -24(%rsi,%r9,8), %rax
61         mul     %rcx
62         sub     %rax, %r8
63         mov     %r8, -24(%rdi,%r9,8)
64         sbb     %rdx, %r8
65 L(3):
66         mov     -16(%rsi,%r9,8), %rax
67         mul     %rcx
68         sub     %rax, %r8
69         mov     %r8, -16(%rdi,%r9,8)
70         sbb     %rdx, %r8
71 L(2):
72         mov     -8(%rsi,%r9,8), %rax
73         mul     %rcx
74         sub     %rax, %r8
75         mov     %r8, -8(%rdi,%r9,8)
76         sbb     %rdx, %r8
77 L(1):
78         mov     (%rsi,%r9,8), %rax
79         mul     %rcx
80         sub     %rax, %r8
81         mov     %r8, (%rdi,%r9,8)
82         sbb     %rdx, %r8
83
84         add     $4, %r9
85         js      L(top)
86 L(end):
87         je      L(3x)
88         cmp     $2, %r9
89         jg      L(ret)
90         mov     $-1, %r9
91         je      L(1)
92         jmp     L(2)
93 L(3x):
94         dec     %r9
95         jmp     L(3)
96
97 L(ret): mov     %r8, %rax
98         ret
99 EPILOGUE()