Text file
src/math/cosh_s390x.s
1 // Copyright 2016 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 // Constants
8 DATA coshrodataL23<>+0(SB)/8, $0.231904681384629956E-16
9 DATA coshrodataL23<>+8(SB)/8, $0.693147180559945286E+00
10 DATA coshrodataL23<>+16(SB)/8, $0.144269504088896339E+01
11 DATA coshrodataL23<>+24(SB)/8, $704.E0
12 GLOBL coshrodataL23<>+0(SB), RODATA, $32
13 DATA coshxinf<>+0(SB)/8, $0x7FF0000000000000
14 GLOBL coshxinf<>+0(SB), RODATA, $8
15 DATA coshxlim1<>+0(SB)/8, $800.E0
16 GLOBL coshxlim1<>+0(SB), RODATA, $8
17 DATA coshxaddhy<>+0(SB)/8, $0xc2f0000100003fdf
18 GLOBL coshxaddhy<>+0(SB), RODATA, $8
19 DATA coshx4ff<>+0(SB)/8, $0x4ff0000000000000
20 GLOBL coshx4ff<>+0(SB), RODATA, $8
21 DATA coshe1<>+0(SB)/8, $0x3ff000000000000a
22 GLOBL coshe1<>+0(SB), RODATA, $8
23
24 // Log multiplier table
25 DATA coshtab<>+0(SB)/8, $0.442737824274138381E-01
26 DATA coshtab<>+8(SB)/8, $0.263602189790660309E-01
27 DATA coshtab<>+16(SB)/8, $0.122565642281703586E-01
28 DATA coshtab<>+24(SB)/8, $0.143757052860721398E-02
29 DATA coshtab<>+32(SB)/8, $-.651375034121276075E-02
30 DATA coshtab<>+40(SB)/8, $-.119317678849450159E-01
31 DATA coshtab<>+48(SB)/8, $-.150868749549871069E-01
32 DATA coshtab<>+56(SB)/8, $-.161992609578469234E-01
33 DATA coshtab<>+64(SB)/8, $-.154492360403337917E-01
34 DATA coshtab<>+72(SB)/8, $-.129850717389178721E-01
35 DATA coshtab<>+80(SB)/8, $-.892902649276657891E-02
36 DATA coshtab<>+88(SB)/8, $-.338202636596794887E-02
37 DATA coshtab<>+96(SB)/8, $0.357266307045684762E-02
38 DATA coshtab<>+104(SB)/8, $0.118665304327406698E-01
39 DATA coshtab<>+112(SB)/8, $0.214434994118118914E-01
40 DATA coshtab<>+120(SB)/8, $0.322580645161290314E-01
41 GLOBL coshtab<>+0(SB), RODATA, $128
42
43 // Minimax polynomial approximations
44 DATA coshe2<>+0(SB)/8, $0.500000000000004237e+00
45 GLOBL coshe2<>+0(SB), RODATA, $8
46 DATA coshe3<>+0(SB)/8, $0.166666666630345592e+00
47 GLOBL coshe3<>+0(SB), RODATA, $8
48 DATA coshe4<>+0(SB)/8, $0.416666664838056960e-01
49 GLOBL coshe4<>+0(SB), RODATA, $8
50 DATA coshe5<>+0(SB)/8, $0.833349307718286047e-02
51 GLOBL coshe5<>+0(SB), RODATA, $8
52 DATA coshe6<>+0(SB)/8, $0.138926439368309441e-02
53 GLOBL coshe6<>+0(SB), RODATA, $8
54
55 // Cosh returns the hyperbolic cosine of x.
56 //
57 // Special cases are:
58 // Cosh(±0) = 1
59 // Cosh(±Inf) = +Inf
60 // Cosh(NaN) = NaN
61 // The algorithm used is minimax polynomial approximation
62 // with coefficients determined with a Remez exchange algorithm.
63
64 TEXT ·coshAsm(SB),NOSPLIT,$0-16
65 FMOVD x+0(FP), F0
66 MOVD $coshrodataL23<>+0(SB), R9
67 LTDBR F0, F0
68 MOVD $0x4086000000000000, R2
69 MOVD $0x4086000000000000, R3
70 BLTU L19
71 FMOVD F0, F4
72 L2:
73 WORD $0xED409018 //cdb %f4,.L24-.L23(%r9)
74 BYTE $0x00
75 BYTE $0x19
76 BGE L14 //jnl .L14
77 BVS L14
78 WFCEDBS V4, V4, V2
79 BEQ L20
80 L1:
81 FMOVD F0, ret+8(FP)
82 RET
83
84 L14:
85 WFCEDBS V4, V4, V2
86 BVS L1
87 MOVD $coshxlim1<>+0(SB), R1
88 FMOVD 0(R1), F2
89 WFCHEDBS V4, V2, V2
90 BEQ L21
91 MOVD $coshxaddhy<>+0(SB), R1
92 FMOVD coshrodataL23<>+16(SB), F5
93 FMOVD 0(R1), F2
94 WFMSDB V0, V5, V2, V5
95 FMOVD coshrodataL23<>+8(SB), F3
96 FADD F5, F2
97 MOVD $coshe6<>+0(SB), R1
98 WFMSDB V2, V3, V0, V3
99 FMOVD 0(R1), F6
100 WFMDB V3, V3, V1
101 MOVD $coshe4<>+0(SB), R1
102 FMOVD coshrodataL23<>+0(SB), F7
103 WFMADB V2, V7, V3, V2
104 FMOVD 0(R1), F3
105 MOVD $coshe5<>+0(SB), R1
106 WFMADB V1, V6, V3, V6
107 FMOVD 0(R1), F7
108 MOVD $coshe3<>+0(SB), R1
109 FMOVD 0(R1), F3
110 WFMADB V1, V7, V3, V7
111 FNEG F2, F3
112 LGDR F5, R1
113 MOVD $coshe2<>+0(SB), R3
114 WFCEDBS V4, V0, V0
115 FMOVD 0(R3), F5
116 MOVD $coshe1<>+0(SB), R3
117 WFMADB V1, V6, V5, V6
118 FMOVD 0(R3), F5
119 RISBGN $0, $15, $48, R1, R2
120 WFMADB V1, V7, V5, V1
121 BVS L22
122 RISBGZ $57, $60, $3, R1, R4
123 MOVD $coshtab<>+0(SB), R3
124 WFMADB V3, V6, V1, V6
125 WORD $0x68043000 //ld %f0,0(%r4,%r3)
126 FMSUB F0, F3, F2
127 WORD $0xA71AF000 //ahi %r1,-4096
128 WFMADB V2, V6, V0, V6
129 L17:
130 RISBGN $0, $15, $48, R1, R2
131 LDGR R2, F2
132 FMADD F2, F6, F2
133 MOVD $coshx4ff<>+0(SB), R1
134 FMOVD 0(R1), F0
135 FMUL F2, F0
136 FMOVD F0, ret+8(FP)
137 RET
138
139 L19:
140 FNEG F0, F4
141 BR L2
142 L20:
143 MOVD $coshxaddhy<>+0(SB), R1
144 FMOVD coshrodataL23<>+16(SB), F3
145 FMOVD 0(R1), F2
146 WFMSDB V0, V3, V2, V3
147 FMOVD coshrodataL23<>+8(SB), F4
148 FADD F3, F2
149 MOVD $coshe6<>+0(SB), R1
150 FMSUB F4, F2, F0
151 FMOVD 0(R1), F6
152 WFMDB V0, V0, V1
153 MOVD $coshe4<>+0(SB), R1
154 FMOVD 0(R1), F4
155 MOVD $coshe5<>+0(SB), R1
156 FMOVD coshrodataL23<>+0(SB), F5
157 WFMADB V1, V6, V4, V6
158 FMADD F5, F2, F0
159 FMOVD 0(R1), F2
160 MOVD $coshe3<>+0(SB), R1
161 FMOVD 0(R1), F4
162 WFMADB V1, V2, V4, V2
163 MOVD $coshe2<>+0(SB), R1
164 FMOVD 0(R1), F5
165 FNEG F0, F4
166 WFMADB V1, V6, V5, V6
167 MOVD $coshe1<>+0(SB), R1
168 FMOVD 0(R1), F5
169 WFMADB V1, V2, V5, V1
170 LGDR F3, R1
171 MOVD $coshtab<>+0(SB), R5
172 WFMADB V4, V6, V1, V3
173 RISBGZ $57, $60, $3, R1, R4
174 WFMSDB V4, V6, V1, V6
175 WORD $0x68145000 //ld %f1,0(%r4,%r5)
176 WFMSDB V4, V1, V0, V2
177 WORD $0xA7487FBE //lhi %r4,32702
178 FMADD F3, F2, F1
179 SUBW R1, R4
180 RISBGZ $57, $60, $3, R4, R12
181 WORD $0x682C5000 //ld %f2,0(%r12,%r5)
182 FMSUB F2, F4, F0
183 RISBGN $0, $15, $48, R1, R2
184 WFMADB V0, V6, V2, V6
185 RISBGN $0, $15, $48, R4, R3
186 LDGR R2, F2
187 LDGR R3, F0
188 FMADD F2, F1, F2
189 FMADD F0, F6, F0
190 FADD F2, F0
191 FMOVD F0, ret+8(FP)
192 RET
193
194 L22:
195 WORD $0xA7387FBE //lhi %r3,32702
196 MOVD $coshtab<>+0(SB), R4
197 SUBW R1, R3
198 WFMSDB V3, V6, V1, V6
199 RISBGZ $57, $60, $3, R3, R3
200 WORD $0x68034000 //ld %f0,0(%r3,%r4)
201 FMSUB F0, F3, F2
202 WORD $0xA7386FBE //lhi %r3,28606
203 WFMADB V2, V6, V0, V6
204 SUBW R1, R3, R1
205 BR L17
206 L21:
207 MOVD $coshxinf<>+0(SB), R1
208 FMOVD 0(R1), F0
209 FMOVD F0, ret+8(FP)
210 RET
211
212
View as plain text