1
0
mirror of https://github.com/golang/go synced 2024-11-14 09:00:21 -07:00
go/src/math/tan_s390x.s

111 lines
2.8 KiB
ArmAsm
Raw Normal View History

math: use SIMD to accelerate additional scalar math functions on s390x As necessary, math functions were structured to use stubs, so that they can be accelerated with assembly on any platform. Technique used was minimax polynomial approximation using tables of polynomial coefficients, with argument range reduction. Benchmark New Old Speedup BenchmarkAcos 12.2 47.5 3.89 BenchmarkAcosh 18.5 56.2 3.04 BenchmarkAsin 13.1 40.6 3.10 BenchmarkAsinh 19.4 62.8 3.24 BenchmarkAtan 10.1 23 2.28 BenchmarkAtanh 19.1 53.2 2.79 BenchmarkAtan2 16.5 33.9 2.05 BenchmarkCbrt 14.8 58 3.92 BenchmarkErf 10.8 20.1 1.86 BenchmarkErfc 11.2 23.5 2.10 BenchmarkExp 8.77 53.8 6.13 BenchmarkExpm1 10.1 38.3 3.79 BenchmarkLog 13.1 40.1 3.06 BenchmarkLog1p 12.7 38.3 3.02 BenchmarkPowInt 31.7 40.5 1.28 BenchmarkPowFrac 33.1 141 4.26 BenchmarkTan 11.5 30 2.61 Accuracy was tested against a high precision reference function to determine maximum error. Note: ulperr is error in "units in the last place" max ulperr Acos 1.15 Acosh 1.07 Asin 2.22 Asinh 1.72 Atan 1.41 Atanh 3.00 Atan2 1.45 Cbrt 1.18 Erf 1.29 Erfc 4.82 Exp 1.00 Expm1 2.26 Log 0.94 Log1p 2.39 Tan 3.14 Pow will have 99.99% correctly rounded results with reasonable inputs producing numeric (non Inf or NaN) results Change-Id: I850e8cf7b70426e8b54ec49d74acd4cddc8c6cb2 Reviewed-on: https://go-review.googlesource.com/38585 Reviewed-by: Michael Munday <munday@ca.ibm.com> Run-TryBot: Michael Munday <munday@ca.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-24 14:43:02 -06:00
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "textflag.h"
// Minimax polynomial approximations
DATA ·tanrodataL13<> + 0(SB)/8, $0.181017336383229927e-07
DATA ·tanrodataL13<> + 8(SB)/8, $-.256590857271311164e-03
DATA ·tanrodataL13<> + 16(SB)/8, $-.464359274328689195e+00
DATA ·tanrodataL13<> + 24(SB)/8, $1.0
DATA ·tanrodataL13<> + 32(SB)/8, $-.333333333333333464e+00
DATA ·tanrodataL13<> + 40(SB)/8, $0.245751217306830032e-01
DATA ·tanrodataL13<> + 48(SB)/8, $-.245391301343844510e-03
DATA ·tanrodataL13<> + 56(SB)/8, $0.214530914428992319e-01
DATA ·tanrodataL13<> + 64(SB)/8, $0.108285667160535624e-31
DATA ·tanrodataL13<> + 72(SB)/8, $0.612323399573676480e-16
DATA ·tanrodataL13<> + 80(SB)/8, $0.157079632679489656e+01
DATA ·tanrodataL13<> + 88(SB)/8, $0.636619772367581341e+00
GLOBL ·tanrodataL13<> + 0(SB), RODATA, $96
// Constants
DATA ·tanxnan<> + 0(SB)/8, $0x7ff8000000000000
GLOBL ·tanxnan<> + 0(SB), RODATA, $8
DATA ·tanxlim<> + 0(SB)/8, $0x432921fb54442d19
GLOBL ·tanxlim<> + 0(SB), RODATA, $8
DATA ·tanxadd<> + 0(SB)/8, $0xc338000000000000
GLOBL ·tanxadd<> + 0(SB), RODATA, $8
// Tan returns the tangent of the radian argument.
//
// Special cases are:
// Tan(±0) = ±0
// Tan(±Inf) = NaN
// Tan(NaN) = NaN
// The algorithm used is minimax polynomial approximation using a table of
// polynomial coefficients determined with a Remez exchange algorithm.
TEXT ·tanAsm(SB), NOSPLIT, $0-16
FMOVD x+0(FP), F0
//specail case Tan(±0) = ±0
FMOVD $(0.0), F1
FCMPU F0, F1
BEQ atanIsZero
MOVD $·tanrodataL13<>+0(SB), R5
WORD $0xB3120000 //ltdbr %f0,%f0
BLTU L10
FMOVD F0, F2
L2:
MOVD $·tanxlim<>+0(SB), R1
WORD $0xED201000 //cdb %f2,0(%r1)
BYTE $0x00
BYTE $0x19
BGE L11
BVS L11
MOVD $·tanxadd<>+0(SB), R1
FMOVD 88(R5), F6
FMOVD 0(R1), F4
WFMSDB V0, V6, V4, V6
FMOVD 80(R5), F1
FADD F6, F4
FMOVD 72(R5), F2
FMSUB F1, F4, F0
FMOVD 64(R5), F3
WFMADB V4, V2, V0, V2
FMOVD 56(R5), F1
WFMADB V4, V3, V2, V4
FMUL F2, F2
VLEG $0, 48(R5), V18
WORD $0xB3CD0016 //lgdr %r1,%f6
FMOVD 40(R5), F5
FMOVD 32(R5), F3
FMADD F1, F2, F3
FMOVD 24(R5), F1
FMOVD 16(R5), F7
FMOVD 8(R5), F0
WFMADB V2, V7, V1, V7
WFMADB V2, V0, V5, V0
WFMDB V2, V2, V1
FMOVD 0(R5), F5
WFLCDB V4, V16
WFMADB V2, V5, V18, V5
WFMADB V1, V0, V7, V0
WORD $0xA7110001 //tmll %r1,1
WFMADB V1, V5, V3, V1
BNE L12
WFDDB V0, V1, V0
WFMDB V2, V16, V2
WFMADB V2, V0, V4, V0
WORD $0xB3130000 //lcdbr %f0,%f0
FMOVD F0, ret+8(FP)
RET
L12:
WFMSDB V2, V1, V0, V2
WFMDB V16, V2, V2
FDIV F2, F0
FMOVD F0, ret+8(FP)
RET
L11:
MOVD $·tanxnan<>+0(SB), R1
FMOVD 0(R1), F0
FMOVD F0, ret+8(FP)
RET
L10:
WORD $0xB3130020 //lcdbr %f2,%f0
BR L2
atanIsZero:
FMOVD F0, ret+8(FP)
RET