Debian Codegraph @

mpn/powerpc64/mode64/p9/add_n_sub_n.asm

raw
1 dnl PowerPC-64 mpn_add_n_sub_n optimised for POWER9.
2
3 dnl Copyright 2018 Free Software Foundation, Inc.
4
5 dnl This file is part of the GNU MP Library.
6 dnl
7 dnl The GNU MP Library is free software; you can redistribute it and/or modify
8 dnl it under the terms of either:
9 dnl
10 dnl * the GNU Lesser General Public License as published by the Free
11 dnl Software Foundation; either version 3 of the License, or (at your
12 dnl option) any later version.
13 dnl
14 dnl or
15 dnl
16 dnl * the GNU General Public License as published by the Free Software
17 dnl Foundation; either version 2 of the License, or (at your option) any
18 dnl later version.
19 dnl
20 dnl or both in parallel, as here.
21 dnl
22 dnl The GNU MP Library is distributed in the hope that it will be useful, but
23 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 dnl for more details.
26 dnl
27 dnl You should have received copies of the GNU General Public License and the
28 dnl GNU Lesser General Public License along with the GNU MP Library. If not,
29 dnl see https://www.gnu.org/licenses/.
30
31 include(`../config.m4')
32
33 C cycles/limb
34 C POWER3/PPC630 -
35 C POWER4/PPC970 -
36 C POWER5 -
37 C POWER6 -
38 C POWER7 -
39 C POWER8 -
40 C POWER9 2.25
41
42
43 C INPUT PARAMETERS
44 define(`arp', `r3')
45 define(`srp', `r4')
46 define(`up', `r5')
47 define(`vp', `r6')
48 define(`n', `r7')
49
50 ASM_START()
51 PROLOGUE(mpn_add_n_sub_n)
52 cmpdi cr7, n, 2
53 subfo r0, r0, r0 C clear OV
54 rldicl. r9, n, 0, 63 C n & 1
55 beq cr0, L(bx0)
56
57 L(bx1): ld r10, 0(up)
58 ld r11, 0(vp)
59 ble cr7, L(1)
60 srdi r7, r7, 1
61 mtctr r7
62 ld r8, 8(up)
63 ld r9, 8(vp)
64 addex( r0, r10, r11, 0)
65 subfc r12, r11, r10
66 addi up, up, -8
67 addi vp, vp, -8
68 b L(lo1)
69
70 L(bx0): ld r8, 0(up)
71 ld r9, 0(vp)
72 ld r10, 8(up)
73 ld r11, 8(vp)
74 addex( r0, r8, r9, 0)
75 subfc r12, r9, r8
76 addi arp, arp, 8
77 addi srp, srp, 8
78 ble cr7, L(end)
79 addi r7, r7, -1
80 srdi r7, r7, 1
81 mtctr r7
82
83 L(top): ld r8, 16(up)
84 ld r9, 16(vp)
85 std r0, -8(arp)
86 std r12, -8(srp)
87 addex( r0, r10, r11, 0)
88 subfe r12, r11, r10
89 L(lo1): ld r10, 24(up)
90 ld r11, 24(vp)
91 std r0, 0(arp)
92 std r12, 0(srp)
93 addex( r0, r8, r9, 0)
94 subfe r12, r9, r8
95 addi up, up, 16
96 addi vp, vp, 16
97 addi arp, arp, 16
98 addi srp, srp, 16
99 bdnz L(top)
100
101 L(end): std r0, -8(arp)
102 std r12, -8(srp)
103 L(1): addex( r0, r10, r11, 0)
104 subfe r12, r11, r10
105 std r0, 0(arp)
106 std r12, 0(srp)
107 subfe r3, r3, r3
108 addex( r3, r3, r3, 0)
109 rldicl r3, r3, 1, 62
110 blr
111 EPILOGUE()
112 ASM_END()