From 8149db4f64aa72407d8be2184d0b414b535cd124 Mon Sep 17 00:00:00 2001 From: erifan01 Date: Tue, 22 May 2018 06:58:32 +0000 Subject: cmd/compile: intrinsify math.RoundToEven and math.Abs on arm64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit math.RoundToEven can be done by one arm64 instruction FRINTND, intrinsify it to improve performance. The current pure Go implementation of the function Abs is translated into five instructions on arm64: str, ldr, and, str, ldr. The intrinsic implementation requires only one instruction, so in terms of performance, intrinsify it is worthwhile. Benchmarks: name old time/op new time/op delta Abs-8 3.50ns ± 0% 1.50ns ± 0% -57.14% (p=0.000 n=10+10) RoundToEven-8 9.26ns ± 0% 1.50ns ± 0% -83.80% (p=0.000 n=10+10) Change-Id: I9456b26ab282b544dfac0154fc86f17aed96ac3d Reviewed-on: https://go-review.googlesource.com/116535 Reviewed-by: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot --- test/codegen/math.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/math.go b/test/codegen/math.go index 3d5f0917ef..6afe183345 100644 --- a/test/codegen/math.go +++ b/test/codegen/math.go @@ -32,6 +32,7 @@ func approx(x float64) { sink64[3] = math.Trunc(x) // s390x:"FIDBR\t[$]4" + // arm64:"FRINTND" sink64[4] = math.RoundToEven(x) } @@ -48,6 +49,7 @@ func sqrt(x float64) float64 { // Check that it's using integer registers func abs(x, y float64) { // amd64:"BTRQ\t[$]63" + // arm64:"FABSD\t" // s390x:"LPDFR\t",-"MOVD\t" (no integer load/store) // ppc64le:"FABS\t" sink64[0] = math.Abs(x) -- cgit v1.3-5-g9baa