summaryrefslogtreecommitdiff
path: root/mpn/x86/atom/sse2/mul_1.asm
blob: 5cd86caecffa890b5163f72769de61521fda348d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
dnl  Intel Atom mpn_mul_1.

dnl  Contributed to the GNU project by Torbjorn Granlund and Marco Bodrato.
dnl
dnl  Copyright 2011 Free Software Foundation, Inc.
dnl
dnl  This file is part of the GNU MP Library.
dnl
dnl  The GNU MP Library is free software; you can redistribute it and/or
dnl  modify it under the terms of the GNU Lesser General Public License as
dnl  published by the Free Software Foundation; either version 3 of the
dnl  License, or (at your option) any later version.
dnl
dnl  The GNU MP Library is distributed in the hope that it will be useful,
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dnl  Lesser General Public License for more details.
dnl
dnl  You should have received a copy of the GNU Lesser General Public License
dnl  along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.

include(`../config.m4')

C			    cycles/limb
C			    cycles/limb
C P5				 -
C P6 model 0-8,10-12		 -
C P6 model 9  (Banias)
C P6 model 13 (Dothan)
C P4 model 0  (Willamette)
C P4 model 1  (?)
C P4 model 2  (Northwood)
C P4 model 3  (Prescott)
C P4 model 4  (Nocona)
C Intel Atom			 7.5
C AMD K6			 -
C AMD K7			 -
C AMD K8
C AMD K10

defframe(PARAM_CARRY,20)
defframe(PARAM_MUL,  16)
defframe(PARAM_SIZE, 12)
defframe(PARAM_SRC,  8)
defframe(PARAM_DST,  4)

define(`rp', `%edx')
define(`up', `%esi')
define(`n',  `%ecx')

ASM_START()
	TEXT
	ALIGN(16)
deflit(`FRAME',0)

PROLOGUE(mpn_mul_1c)
	movd	PARAM_CARRY, %mm6	C carry
	jmp	L(ent)
EPILOGUE()

	ALIGN(8)			C for compact code
PROLOGUE(mpn_mul_1)
	pxor	%mm6, %mm6
L(ent):	push	%esi			FRAME_pushl()
	mov	PARAM_SRC, up
	mov	PARAM_SIZE, %eax	C size
	movd	PARAM_MUL, %mm7
	movd	(up), %mm0
	mov	%eax, n
	and	$3, %eax
	pmuludq	%mm7, %mm0
	mov	PARAM_DST, rp
	jz	L(lo0)
	cmp	$2, %eax
	lea	-16(up,%eax,4),up
	lea	-16(rp,%eax,4),rp
	jc	L(lo1)
	jz	L(lo2)
	jmp	L(lo3)

	ALIGN(16)
L(top):	movd	(up), %mm0
	pmuludq	%mm7, %mm0
	psrlq	$32, %mm6
	lea	16(rp), rp
L(lo0):	paddq	%mm0, %mm6
	movd	4(up), %mm0
	pmuludq	%mm7, %mm0
	movd	%mm6, (rp)
	psrlq	$32, %mm6
L(lo3):	paddq	%mm0, %mm6
	movd	8(up), %mm0
	pmuludq	%mm7, %mm0
	movd	%mm6, 4(rp)
	psrlq	$32, %mm6
L(lo2):	paddq	%mm0, %mm6
	movd	12(up), %mm0
	pmuludq	%mm7, %mm0
	movd	%mm6, 8(rp)
	psrlq	$32, %mm6
L(lo1):	paddq	%mm0, %mm6
	sub	$4, n
	movd	%mm6, 12(rp)
	lea	16(up), up
	ja	L(top)

	psrlq	$32, %mm6
	movd	%mm6, %eax
	emms
	pop	%esi			FRAME_popl()
	ret
EPILOGUE()
ASM_END()