blob: 87a5d00154dfec0186f8c3c934271e1940b9114e [file] [log] [blame]
Dan Willemsenc78f7142017-07-26 13:08:14 -07001// Copyright 2017 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#include "textflag.h"
6
7// Minimax polynomial coefficients and other constants
8DATA ·acoshrodataL11<> + 0(SB)/8, $-1.0
9DATA ·acoshrodataL11<> + 8(SB)/8, $.41375273347623353626
10DATA ·acoshrodataL11<> + 16(SB)/8, $.51487302528619766235E+04
11DATA ·acoshrodataL11<> + 24(SB)/8, $-1.67526912689208984375
12DATA ·acoshrodataL11<> + 32(SB)/8, $0.181818181818181826E+00
13DATA ·acoshrodataL11<> + 40(SB)/8, $-.165289256198351540E-01
14DATA ·acoshrodataL11<> + 48(SB)/8, $0.200350613573012186E-02
15DATA ·acoshrodataL11<> + 56(SB)/8, $-.273205381970859341E-03
16DATA ·acoshrodataL11<> + 64(SB)/8, $0.397389654305194527E-04
17DATA ·acoshrodataL11<> + 72(SB)/8, $0.938370938292558173E-06
18DATA ·acoshrodataL11<> + 80(SB)/8, $-.602107458843052029E-05
19DATA ·acoshrodataL11<> + 88(SB)/8, $0.212881813645679599E-07
20DATA ·acoshrodataL11<> + 96(SB)/8, $-.148682720127920854E-06
21DATA ·acoshrodataL11<> + 104(SB)/8, $-5.5
22DATA ·acoshrodataL11<> + 112(SB)/8, $0x7ff8000000000000 //Nan
23GLOBL ·acoshrodataL11<> + 0(SB), RODATA, $120
24
25// Table of log correction terms
26DATA ·acoshtab2068<> + 0(SB)/8, $0.585235384085551248E-01
27DATA ·acoshtab2068<> + 8(SB)/8, $0.412206153771168640E-01
28DATA ·acoshtab2068<> + 16(SB)/8, $0.273839003221648339E-01
29DATA ·acoshtab2068<> + 24(SB)/8, $0.166383778368856480E-01
30DATA ·acoshtab2068<> + 32(SB)/8, $0.866678223433169637E-02
31DATA ·acoshtab2068<> + 40(SB)/8, $0.319831684989627514E-02
32DATA ·acoshtab2068<> + 48(SB)/8, $0.0
33DATA ·acoshtab2068<> + 56(SB)/8, $-.113006378583725549E-02
34DATA ·acoshtab2068<> + 64(SB)/8, $-.367979419636602491E-03
35DATA ·acoshtab2068<> + 72(SB)/8, $0.213172484510484979E-02
36DATA ·acoshtab2068<> + 80(SB)/8, $0.623271047682013536E-02
37DATA ·acoshtab2068<> + 88(SB)/8, $0.118140812789696885E-01
38DATA ·acoshtab2068<> + 96(SB)/8, $0.187681358930914206E-01
39DATA ·acoshtab2068<> + 104(SB)/8, $0.269985148668178992E-01
40DATA ·acoshtab2068<> + 112(SB)/8, $0.364186619761331328E-01
41DATA ·acoshtab2068<> + 120(SB)/8, $0.469505379381388441E-01
42GLOBL ·acoshtab2068<> + 0(SB), RODATA, $128
43
44// Acosh returns the inverse hyperbolic cosine of the argument.
45//
46// Special cases are:
47// Acosh(+Inf) = +Inf
48// Acosh(x) = NaN if x < 1
49// Acosh(NaN) = NaN
50// The algorithm used is minimax polynomial approximation
51// with coefficients determined with a Remez exchange algorithm.
52
53TEXT ·acoshAsm(SB), NOSPLIT, $0-16
54 FMOVD x+0(FP), F0
55 MOVD $·acoshrodataL11<>+0(SB), R9
Colin Cross1371fe42019-03-19 21:08:48 -070056 LGDR F0, R1
Dan Willemsenc78f7142017-07-26 13:08:14 -070057 WORD $0xC0295FEF //iilf %r2,1609564159
58 BYTE $0xFF
59 BYTE $0xFF
60 SRAD $32, R1
61 CMPW R1, R2
62 BGT L2
63 WORD $0xC0293FEF //iilf %r2,1072693247
64 BYTE $0xFF
65 BYTE $0xFF
66 CMPW R1, R2
67 BGT L10
68L3:
69 WFCEDBS V0, V0, V2
70 BVS L1
71 FMOVD 112(R9), F0
72L1:
73 FMOVD F0, ret+8(FP)
74 RET
75L2:
76 WORD $0xC0297FEF //iilf %r2,2146435071
77 BYTE $0xFF
78 BYTE $0xFF
79 MOVW R1, R6
80 MOVW R2, R7
81 CMPBGT R6, R7, L1
82 FMOVD F0, F8
83 FMOVD $0, F0
84 WFADB V0, V8, V0
85 WORD $0xC0398006 //iilf %r3,2147909631
86 BYTE $0x7F
87 BYTE $0xFF
Colin Cross1371fe42019-03-19 21:08:48 -070088 LGDR F0, R5
Dan Willemsenc78f7142017-07-26 13:08:14 -070089 SRAD $32, R5
90 MOVH $0x0, R1
91 SUBW R5, R3
92 FMOVD $0, F10
93 WORD $0xEC4320AF //risbg %r4,%r3,32,128+47,0
94 BYTE $0x00
95 BYTE $0x55
96 WORD $0xEC3339BC //risbg %r3,%r3,57,128+60,64-13
97 BYTE $0x33
98 BYTE $0x55
99 BYTE $0x18 //lr %r2,%r4
100 BYTE $0x24
101 WORD $0xEC14001F //risbgn %r1,%r4,64-64+0,64-64+0+32-1,64-0-32
102 BYTE $0x20
103 BYTE $0x59
104 SUBW $0x100000, R2
105 SRAW $8, R2, R2
106 ORW $0x45000000, R2
107L5:
Colin Cross1371fe42019-03-19 21:08:48 -0700108 LDGR R1, F0
Dan Willemsenc78f7142017-07-26 13:08:14 -0700109 FMOVD 104(R9), F2
110 FMADD F8, F0, F2
111 FMOVD 96(R9), F4
112 WFMADB V10, V0, V2, V0
113 FMOVD 88(R9), F6
114 FMOVD 80(R9), F2
115 WFMADB V0, V6, V4, V6
116 FMOVD 72(R9), F1
117 WFMDB V0, V0, V4
118 WFMADB V0, V1, V2, V1
119 FMOVD 64(R9), F2
120 WFMADB V6, V4, V1, V6
121 FMOVD 56(R9), F1
122 WORD $0xEC3339BC //risbg %r3,%r3,57,128+60,0
123 BYTE $0x00
124 BYTE $0x55
125 WFMADB V0, V2, V1, V2
126 FMOVD 48(R9), F1
127 WFMADB V4, V6, V2, V6
128 FMOVD 40(R9), F2
129 WFMADB V0, V1, V2, V1
130 VLVGF $0, R2, V2
131 WFMADB V4, V6, V1, V4
132 LDEBR F2, F2
133 FMOVD 32(R9), F6
134 WFMADB V0, V4, V6, V4
135 FMOVD 24(R9), F1
136 FMOVD 16(R9), F6
137 MOVD $·acoshtab2068<>+0(SB), R1
138 WFMADB V2, V1, V6, V2
139 FMOVD 0(R3)(R1*1), F3
140 WFMADB V0, V4, V3, V0
141 FMOVD 8(R9), F4
142 FMADD F4, F2, F0
143 FMOVD F0, ret+8(FP)
144 RET
145L10:
146 FMOVD F0, F8
147 FMOVD 0(R9), F0
148 FMADD F8, F8, F0
Dan Willemsenf3f2eb62018-08-28 11:28:58 -0700149 LTDBR F0, F0
Dan Willemsenc78f7142017-07-26 13:08:14 -0700150 FSQRT F0, F10
151L4:
152 WFADB V10, V8, V0
153 WORD $0xC0398006 //iilf %r3,2147909631
154 BYTE $0x7F
155 BYTE $0xFF
Colin Cross1371fe42019-03-19 21:08:48 -0700156 LGDR F0, R5
Dan Willemsenc78f7142017-07-26 13:08:14 -0700157 SRAD $32, R5
158 MOVH $0x0, R1
159 SUBW R5, R3
160 SRAW $8, R3, R2
161 WORD $0xEC4320AF //risbg %r4,%r3,32,128+47,0
162 BYTE $0x00
163 BYTE $0x55
164 ANDW $0xFFFFFF00, R2
165 WORD $0xEC3339BC //risbg %r3,%r3,57,128+60,64-13
166 BYTE $0x33
167 BYTE $0x55
168 ORW $0x45000000, R2
169 WORD $0xEC14001F //risbgn %r1,%r4,64-64+0,64-64+0+32-1,64-0-32
170 BYTE $0x20
171 BYTE $0x59
172 BR L5