1 // Copyright (c) 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build arm64 && gc && !purego
6 // +build arm64,gc,!purego
7
8 #include "textflag.h"
9
10 // carryPropagate works exactly like carryPropagateGeneric and uses the
11 // same AND, ADD, and LSR+MADD instructions emitted by the compiler, but
12 // avoids loading R0-R4 twice and uses LDP and STP.
13 //
14 // See https://golang.org/issues/43145 for the main compiler issue.
15 //
16 // func carryPropagate(v *Element)
17 TEXT ·carryPropagate(SB),NOFRAME|NOSPLIT,$0-8
18 MOVD v+0(FP), R20
19
20 LDP 0(R20), (R0, R1)
21 LDP 16(R20), (R2, R3)
22 MOVD 32(R20), R4
23
24 AND $0x7ffffffffffff, R0, R10
25 AND $0x7ffffffffffff, R1, R11
26 AND $0x7ffffffffffff, R2, R12
27 AND $0x7ffffffffffff, R3, R13
28 AND $0x7ffffffffffff, R4, R14
29
30 ADD R0>>51, R11, R11
31 ADD R1>>51, R12, R12
32 ADD R2>>51, R13, R13
33 ADD R3>>51, R14, R14
34 // R4>>51 * 19 + R10 -> R10
35 LSR $51, R4, R21
36 MOVD $19, R22
37 MADD R22, R10, R21, R10
38
39 STP (R10, R11), 0(R20)
40 STP (R12, R13), 16(R20)
41 MOVD R14, 32(R20)
42
43 RET
44
View as plain text