Commit 03fb1f60 authored by smasher164's avatar smasher164 Committed by Brad Fitzpatrick

cmd/compile: don't use FMA on plan9

CL 137156 introduces an intrinsic on AMD64 that executes vfmadd231sd
when feature detection is successful. However, because floating-point
isn't allowed in note handler, the builder disables SSE instructions,
and fails when attempting to execute this instruction. This change
disables FMA on plan9 to immediately use the software fallback.

Fixes #35063.

Change-Id: I87d8f0995bd2f15013d203e618938f5079c9eed2
Reviewed-on: https://go-review.googlesource.com/c/go/+/202617Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 48eb79ec
......@@ -3330,6 +3330,11 @@ func init() {
sys.ARM64, sys.PPC64, sys.S390X)
addF("math", "Fma",
func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
if !s.config.UseFMA {
a := s.call(n, callNormal)
s.vars[n] = s.load(types.Types[TFLOAT64], a)
return s.variable(n, types.Types[TFLOAT64])
}
addr := s.entryNewValue1A(ssa.OpAddr, types.Types[TBOOL].PtrTo(), x86HasFMA, s.sb)
v := s.load(types.Types[TBOOL], addr)
b := s.endBlock()
......@@ -3360,6 +3365,11 @@ func init() {
sys.AMD64)
addF("math", "Fma",
func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
if !s.config.UseFMA {
a := s.call(n, callNormal)
s.vars[n] = s.load(types.Types[TFLOAT64], a)
return s.variable(n, types.Types[TFLOAT64])
}
addr := s.entryNewValue1A(ssa.OpAddr, types.Types[TBOOL].PtrTo(), armHasVFPv4, s.sb)
v := s.load(types.Types[TBOOL], addr)
b := s.endBlock()
......
......@@ -43,6 +43,7 @@ type Config struct {
Race bool // race detector enabled
NeedsFpScratch bool // No direct move between GP and FP register sets
BigEndian bool //
UseFMA bool // Use hardware FMA operation
}
type (
......@@ -326,13 +327,19 @@ func NewConfig(arch string, types Types, ctxt *obj.Link, optimize bool) *Config
c.ctxt = ctxt
c.optimize = optimize
c.useSSE = true
c.UseFMA = true
// Don't use Duff's device nor SSE on Plan 9 AMD64, because
// floating point operations are not allowed in note handler.
if objabi.GOOS == "plan9" && arch == "amd64" {
// On Plan 9, floating point operations are not allowed in note handler.
if objabi.GOOS == "plan9" {
// Don't use FMA on Plan 9
c.UseFMA = false
// Don't use Duff's device and SSE on Plan 9 AMD64.
if arch == "amd64" {
c.noDuffDevice = true
c.useSSE = false
}
}
if ctxt.Flag_shared {
// LoweredWB is secretly a CALL and CALLs on 386 in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment