1dnl  ARM64 mpn_sqr_diag_addlsh1.
2
3dnl  Contributed to the GNU project by Torbj��rn Granlund.
4
5dnl  Copyright 2016, 2017 Free Software Foundation, Inc.
6
7dnl  This file is part of the GNU MP Library.
8dnl
9dnl  The GNU MP Library is free software; you can redistribute it and/or modify
10dnl  it under the terms of either:
11dnl
12dnl    * the GNU Lesser General Public License as published by the Free
13dnl      Software Foundation; either version 3 of the License, or (at your
14dnl      option) any later version.
15dnl
16dnl  or
17dnl
18dnl    * the GNU General Public License as published by the Free Software
19dnl      Foundation; either version 2 of the License, or (at your option) any
20dnl      later version.
21dnl
22dnl  or both in parallel, as here.
23dnl
24dnl  The GNU MP Library is distributed in the hope that it will be useful, but
25dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
26dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27dnl  for more details.
28dnl
29dnl  You should have received copies of the GNU General Public License and the
30dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
31dnl  see https://www.gnu.org/licenses/.
32
33include(`../config.m4')
34
35C	     cycles/limb
36C Cortex-A53	 5.65
37C Cortex-A57	 3.5
38C X-Gene	 3.38
39
40changecom(blah)
41
42define(`rp', `x0')
43define(`tp', `x1')
44define(`up', `x2')
45define(`n',  `x3')
46
47ASM_START()
48PROLOGUE(mpn_sqr_diag_addlsh1)
49	ldr	x15, [up],#8
50	lsr	x18, n, #1
51	tbz	n, #0, L(bx0)
52
53L(bx1):	adds	x7, xzr, xzr
54	mul	x12, x15, x15
55	ldr	x16, [up],#8
56	ldp	x4, x5, [tp],#16
57	umulh	x11, x15, x15
58	b	L(mid)
59
60L(bx0):	adds	x5, xzr, xzr
61	mul	x12, x15, x15
62	ldr	x17, [up],#16
63	ldp	x6, x7, [tp],#32
64	umulh	x11, x15, x15
65	sub	x18, x18, #1
66	cbz	x18, L(end)
67
68	ALIGN(16)
69L(top):	extr	x9, x6, x5, #63
70	mul	x10, x17, x17
71	ldr	x16, [up,#-8]
72	adcs	x13, x9, x11
73	ldp	x4, x5, [tp,#-16]
74	umulh	x11, x17, x17
75	extr	x8, x7, x6, #63
76	stp	x12, x13, [rp],#16
77	adcs	x12, x8, x10
78L(mid):	extr	x9, x4, x7, #63
79	mul	x10, x16, x16
80	ldr	x17, [up],#16
81	adcs	x13, x9, x11
82	ldp	x6, x7, [tp],#32
83	umulh	x11, x16, x16
84	extr	x8, x5, x4, #63
85	stp	x12, x13, [rp],#16
86	adcs	x12, x8, x10
87	sub	x18, x18, #1
88	cbnz	x18, L(top)
89
90L(end):	extr	x9, x6, x5, #63
91	mul	x10, x17, x17
92	adcs	x13, x9, x11
93	umulh	x11, x17, x17
94	extr	x8, x7, x6, #63
95	stp	x12, x13, [rp]
96	adcs	x12, x8, x10
97	extr	x9, xzr, x7, #63
98	adcs	x13, x9, x11
99	stp	x12, x13, [rp,#16]
100
101	ret
102EPILOGUE()
103