aboutsummaryrefslogtreecommitdiff
path: root/gmp-6.3.0/mpn/arm64/mul_1.asm
blob: fb965efff7a7c1162577c7d029742c684575333c (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
dnl  ARM64 mpn_mul_1

dnl  Contributed to the GNU project by Torbjörn Granlund.

dnl  Copyright 2013, 2015, 2017 Free Software Foundation, Inc.

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 modify
dnl  it under the terms of either:
dnl
dnl    * the GNU Lesser General Public License as published by the Free
dnl      Software Foundation; either version 3 of the License, or (at your
dnl      option) any later version.
dnl
dnl  or
dnl
dnl    * the GNU General Public License as published by the Free Software
dnl      Foundation; either version 2 of the License, or (at your option) any
dnl      later version.
dnl
dnl  or both in parallel, as here.
dnl
dnl  The GNU MP Library is distributed in the hope that it will be useful, but
dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dnl  for more details.
dnl
dnl  You should have received copies of the GNU General Public License and the
dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
dnl  see https://www.gnu.org/licenses/.

include(`../config.m4')

C	     cycles/limb
C Cortex-A53	7.5-8
C Cortex-A57	 7
C Cortex-A72
C X-Gene	 4
C Apple M1	 1

C TODO
C  * Start first multiply earlier.

changecom(blah)

define(`rp', `x0')
define(`up', `x1')
define(`n',  `x2')
define(`v0', `x3')


PROLOGUE(mpn_mul_1c)
	adds	xzr, xzr, xzr		C clear cy flag
	b	L(com)
EPILOGUE()

PROLOGUE(mpn_mul_1)
	adds	x4, xzr, xzr		C clear register and cy flag
L(com):	lsr	x17, n, #2
	tbnz	n, #0, L(bx1)

L(bx0):	mov	x11, x4
	tbz	n, #1, L(b00)

L(b10):	ldp	x4, x5, [up]
	mul	x8, x4, v0
	umulh	x10, x4, v0
	cbz	x17, L(2)
	ldp	x6, x7, [up,#16]!
	mul	x9, x5, v0
	b	L(mid)-8

L(2):	mul	x9, x5, v0
	b	L(2e)

L(bx1):	ldr	x7, [up],#8
	mul	x9, x7, v0
	umulh	x11, x7, v0
	adds	x9, x9, x4
	str	x9, [rp],#8
	tbnz	n, #1, L(b10)

L(b01):	cbz	x17, L(1)

L(b00):	ldp	x6, x7, [up]
	mul	x8, x6, v0
	umulh	x10, x6, v0
	ldp	x4, x5, [up,#16]
	mul	x9, x7, v0
	adcs	x12, x8, x11
	umulh	x11, x7, v0
	add	rp, rp, #16
	sub	x17, x17, #1
	cbz	x17, L(end)

	ALIGN(16)
L(top):	mul	x8, x4, v0
	ldp	x6, x7, [up,#32]!
	adcs	x13, x9, x10
	umulh	x10, x4, v0
	mul	x9, x5, v0
	stp	x12, x13, [rp,#-16]
	adcs	x12, x8, x11
	umulh	x11, x5, v0
L(mid):	mul	x8, x6, v0
	ldp	x4, x5, [up,#16]
	adcs	x13, x9, x10
	umulh	x10, x6, v0
	mul	x9, x7, v0
	stp	x12, x13, [rp],#32
	adcs	x12, x8, x11
	umulh	x11, x7, v0
	sub	x17, x17, #1
	cbnz	x17, L(top)

L(end):	mul	x8, x4, v0
	adcs	x13, x9, x10
	umulh	x10, x4, v0
	mul	x9, x5, v0
	stp	x12, x13, [rp,#-16]
L(2e):	adcs	x12, x8, x11
	umulh	x11, x5, v0
	adcs	x13, x9, x10
	stp	x12, x13, [rp]
L(1):	adc	x0, x11, xzr
	ret
EPILOGUE()