@@ -56,7 +56,15 @@ func math_Cbrt(x float64) float64 { return math_cbrt(x) }
56
56
func math_cbrt (x float64 ) float64
57
57
58
58
//go:linkname math_Ceil math.Ceil
59
- func math_Ceil (x float64 ) float64 { return math_ceil (x ) }
59
+ func math_Ceil (x float64 ) float64 {
60
+ if GOARCH == "arm64" || GOARCH == "wasm" {
61
+ return llvm_ceil (x )
62
+ }
63
+ return math_ceil (x )
64
+ }
65
+
66
+ //go:export llvm.ceil.f64
67
+ func llvm_ceil (x float64 ) float64
60
68
61
69
//go:linkname math_ceil math.ceil
62
70
func math_ceil (x float64 ) float64
@@ -104,7 +112,15 @@ func math_Exp2(x float64) float64 { return math_exp2(x) }
104
112
func math_exp2 (x float64 ) float64
105
113
106
114
//go:linkname math_Floor math.Floor
107
- func math_Floor (x float64 ) float64 { return math_floor (x ) }
115
+ func math_Floor (x float64 ) float64 {
116
+ if GOARCH == "arm64" || GOARCH == "wasm" {
117
+ return llvm_floor (x )
118
+ }
119
+ return math_floor (x )
120
+ }
121
+
122
+ //go:export llvm.floor.f64
123
+ func llvm_floor (x float64 ) float64
108
124
109
125
//go:linkname math_floor math.floor
110
126
func math_floor (x float64 ) float64
@@ -152,13 +168,29 @@ func math_Log2(x float64) float64 { return math_log2(x) }
152
168
func math_log2 (x float64 ) float64
153
169
154
170
//go:linkname math_Max math.Max
155
- func math_Max (x , y float64 ) float64 { return math_max (x , y ) }
171
+ func math_Max (x , y float64 ) float64 {
172
+ if GOARCH == "arm64" || GOARCH == "wasm" {
173
+ return llvm_maximum (x , y )
174
+ }
175
+ return math_max (x , y )
176
+ }
177
+
178
+ //go:export llvm.maximum.f64
179
+ func llvm_maximum (x , y float64 ) float64
156
180
157
181
//go:linkname math_max math.max
158
182
func math_max (x , y float64 ) float64
159
183
160
184
//go:linkname math_Min math.Min
161
- func math_Min (x , y float64 ) float64 { return math_min (x , y ) }
185
+ func math_Min (x , y float64 ) float64 {
186
+ if GOARCH == "arm64" || GOARCH == "wasm" {
187
+ return llvm_minimum (x , y )
188
+ }
189
+ return math_min (x , y )
190
+ }
191
+
192
+ //go:export llvm.minimum.f64
193
+ func llvm_minimum (x , y float64 ) float64
162
194
163
195
//go:linkname math_min math.min
164
196
func math_min (x , y float64 ) float64
@@ -200,7 +232,15 @@ func math_Sinh(x float64) float64 { return math_sinh(x) }
200
232
func math_sinh (x float64 ) float64
201
233
202
234
//go:linkname math_Sqrt math.Sqrt
203
- func math_Sqrt (x float64 ) float64 { return math_sqrt (x ) }
235
+ func math_Sqrt (x float64 ) float64 {
236
+ if GOARCH == "x86" || GOARCH == "amd64" || GOARCH == "wasm" {
237
+ return llvm_sqrt (x )
238
+ }
239
+ return math_sqrt (x )
240
+ }
241
+
242
+ //go:export llvm.sqrt.f64
243
+ func llvm_sqrt (x float64 ) float64
204
244
205
245
//go:linkname math_sqrt math.sqrt
206
246
func math_sqrt (x float64 ) float64
@@ -218,7 +258,15 @@ func math_Tanh(x float64) float64 { return math_tanh(x) }
218
258
func math_tanh (x float64 ) float64
219
259
220
260
//go:linkname math_Trunc math.Trunc
221
- func math_Trunc (x float64 ) float64 { return math_trunc (x ) }
261
+ func math_Trunc (x float64 ) float64 {
262
+ if GOARCH == "arm64" || GOARCH == "wasm" {
263
+ return llvm_trunc (x )
264
+ }
265
+ return math_trunc (x )
266
+ }
267
+
268
+ //go:export llvm.trunc.f64
269
+ func llvm_trunc (x float64 ) float64
222
270
223
271
//go:linkname math_trunc math.trunc
224
272
func math_trunc (x float64 ) float64
0 commit comments