]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: add fma intrinsic for amd64
authorsmasher164 <aindurti@gmail.com>
Tue, 25 Sep 2018 07:10:33 +0000 (03:10 -0400)
committerKeith Randall <khr@golang.org>
Mon, 21 Oct 2019 16:42:10 +0000 (16:42 +0000)
commit7a6da218b191de13f4f3555c55aab958b09b66bd
tree6f324979a21514735e80b78bb9ce3c5ad64ea72e
parent50f4896b72d16b6538178c8ca851b20655075b7f
cmd/compile: add fma intrinsic for amd64

To permit ssa-level optimization, this change introduces an amd64 intrinsic
that generates the VFMADD231SD instruction for the fused-multiply-add
operation on systems that support it. System support is detected via
cpu.X86.HasFMA. A rewrite rule can then translate the generic ssa intrinsic
("Fma") to VFMADD231SD.

The benchmark compares the software implementation (old) with the intrinsic
(new).

name   old time/op  new time/op  delta
Fma-4  27.2ns ± 1%   1.0ns ± 9%  -96.48%  (p=0.008 n=5+5)

Updates #25819.

Change-Id: I966655e5f96817a5d06dff5942418a3915b09584
Reviewed-on: https://go-review.googlesource.com/c/go/+/137156
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
12 files changed:
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/gc/builtin.go
src/cmd/compile/internal/gc/builtin/runtime.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/gen/AMD64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewriteAMD64.go
src/runtime/cpuflags.go
src/runtime/proc.go
test/codegen/math.go