]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: intrinsify math.RoundToEven and math.Abs on arm64
authorerifan01 <eric.fang@arm.com>
Tue, 22 May 2018 06:58:32 +0000 (06:58 +0000)
committerCherry Zhang <cherryyz@google.com>
Thu, 13 Sep 2018 14:52:51 +0000 (14:52 +0000)
commit8149db4f64aa72407d8be2184d0b414b535cd124
tree0c0699f22bd284fe467d05df24c489bce827e745
parenta2a3dd00c934fa15ad880ee5fe1f64308cbc73a7
cmd/compile: intrinsify math.RoundToEven and math.Abs on arm64

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 <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/arm64/ssa.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/gen/ARM64.rules
src/cmd/compile/internal/ssa/gen/ARM64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewriteARM64.go
test/codegen/math.go