From ea51e223c28babc530df475497de0be4579b5e86 Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Wed, 17 Feb 2021 15:00:34 +0000 Subject: cmd/{asm,compile}: add fused multiply-add support on riscv64 Add support to the assembler for F[N]M{ADD,SUB}[SD] instructions. Argument order is: OP RS1, RS2, RS3, RD Also, add support for the FMA intrinsic to the compiler. Automatic FMA matching is left to a future CL. Change-Id: I47166c7393b2ab6bfc2e42aa8c1a8997c3a071b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/293030 Trust: Michael Munday Run-TryBot: Michael Munday TryBot-Result: Go Bot Reviewed-by: Joel Sing --- test/codegen/math.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/codegen') diff --git a/test/codegen/math.go b/test/codegen/math.go index 04cb4e577d..cd573db7b3 100644 --- a/test/codegen/math.go +++ b/test/codegen/math.go @@ -125,9 +125,25 @@ func fma(x, y, z float64) float64 { // s390x:"FMADD" // ppc64:"FMADD" // ppc64le:"FMADD" + // riscv64:"FMADDD" return math.FMA(x, y, z) } +func fms(x, y, z float64) float64 { + // riscv64:"FMSUBD" + return math.FMA(x, y, -z) +} + +func fnma(x, y, z float64) float64 { + // riscv64:"FNMADDD" + return math.FMA(-x, y, z) +} + +func fnms(x, y, z float64) float64 { + // riscv64:"FNMSUBD" + return math.FMA(x, -y, -z) +} + func fromFloat64(f64 float64) uint64 { // amd64:"MOVQ\tX.*, [^X].*" // arm64:"FMOVD\tF.*, R.*" -- cgit v1.3-5-g9baa