From 3fce1115359c4ab7d67fbf4efef1341e52b354b7 Mon Sep 17 00:00:00 2001 From: Meng Zhuo Date: Tue, 27 Jun 2023 23:22:04 +0800 Subject: cmd/compile: fix FMA negative commutativity of riscv64 According to RISCV manual 11.6: FMADD x,y,z computes x*y+z and FNMADD x,y,z => -x*y-z FMSUB x,y,z => x*y-z FNMSUB x,y,z => -x*y+z respectively However our implement of SSA convert FMADD -x,y,z to FNMADD x,y,z which is wrong and should be convert to FNMSUB according to manual. Change-Id: Ib297bc83824e121fd7dda171ed56ea9694a4e575 Reviewed-on: https://go-review.googlesource.com/c/go/+/506575 Run-TryBot: M Zhuo Reviewed-by: Keith Randall Reviewed-by: David Chase Reviewed-by: Joedian Reid Reviewed-by: Michael Munday TryBot-Result: Gopher Robot --- test/codegen/math.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/codegen') diff --git a/test/codegen/math.go b/test/codegen/math.go index 6a7d304afd..331ebbe609 100644 --- a/test/codegen/math.go +++ b/test/codegen/math.go @@ -143,13 +143,13 @@ func fms(x, y, z float64) float64 { return math.FMA(x, y, -z) } -func fnma(x, y, z float64) float64 { - // riscv64:"FNMADDD" +func fnms(x, y, z float64) float64 { + // riscv64:"FNMSUBD",-"FNMADDD" return math.FMA(-x, y, z) } -func fnms(x, y, z float64) float64 { - // riscv64:"FNMSUBD" +func fnma(x, y, z float64) float64 { + // riscv64:"FNMADDD",-"FNMSUBD" return math.FMA(x, -y, -z) } -- cgit v1.3-5-g9baa