Debian Codegraph @

mpn/powerpc64/mode64/p9/mul_1.asm

raw
1 dnl Power9 mpn_mul_1.
2
3 dnl Copyright 2017, 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.47
41
42 C TODO
43 C * Schedule for Power9 pipeline.
44 C * Unroll 4x if that proves beneficial.
45 C * This is marginally faster (but much smaller) than ../mul_1.asm.
46
47 C INPUT PARAMETERS
48 define(`rp', `r3')
49 define(`up', `r4')
50 define(`n', `r5')
51 define(`v0', `r6')
52
53 ASM_START()
54 PROLOGUE(mpn_mul_1c)
55 b L(ent)
56 EPILOGUE()
57 PROLOGUE(mpn_mul_1)
58 li r7, 0
59 L(ent): ld r11, 0(up)
60 cmpdi cr6, n, 2
61 addi r0, n, -1 C FIXME: postpone
62 srdi r0, r0, 1 C FIXME: postpone
63 mtctr r0 C FIXME: postpone
64 rldicl. r12, n, 0,63 C r0 = n & 3, set cr0
65 bne cr0, L(b1)
66
67 L(b0): ld r0, 8(up)
68 maddld( r9, r11, v0, r7)
69 maddhdu(r7, r11, v0, r7)
70 ble cr6, L(2)
71 ld r12, 16(up)
72 mulld r8, r0, v0
73 mulhdu r5, r0, v0
74 addic up, up, 16
75 addi rp, rp, -8
76 b L(mid)
77
78 L(b1): ld r0, 0(up)
79 ble cr6, L(1)
80 ld r12, 8(up)
81 maddld( r8, r11, v0, r7)
82 maddhdu(r5, r11, v0, r7)
83 ld r0, 16(up)
84 mulld r9, r12, v0
85 mulhdu r7, r12, v0
86 addic up, up, 24
87 bdz L(end)
88
89 ALIGN(16)
90 L(top): ld r12, 0(up)
91 std r8, 0(rp)
92 adde r9, r5, r9
93 mulld r8, r0, v0
94 mulhdu r5, r0, v0
95 L(mid): ld r0, 8(up)
96 std r9, 8(rp)
97 adde r8, r7, r8
98 mulld r9, r12, v0
99 mulhdu r7, r12, v0
100 addi rp, rp, 16
101 addi up, up, 16
102 bdnz L(top)
103
104 L(end): std r8, 0(rp)
105 mulld r8, r0, v0
106 adde r9, r5, r9
107 mulhdu r5, r0, v0
108 std r9, 8(rp)
109 adde r8, r7, r8
110 std r8, 16(rp)
111 addze r3, r5
112 blr
113
114 L(2): mulld r8, r0, v0
115 mulhdu r5, r0, v0
116 std r9, 0(rp)
117 addc r8, r7, r8
118 std r8, 8(rp)
119 addze r3, r5
120 blr
121
122 L(1): maddld( r8, r0, v0, r7)
123 std r8, 0(rp)
124 maddhdu(r3, r0, v0, r7)
125 blr
126 EPILOGUE()