]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't use FMA on plan9
authorsmasher164 <aindurti@gmail.com>
Tue, 22 Oct 2019 14:09:55 +0000 (10:09 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 22 Oct 2019 19:36:42 +0000 (19:36 +0000)
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/+/202617
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/ssa/config.go

index bbedbbc5aaa2572f191687c126957a9ad5585e36..72727cab9c251a910c89332186c59d8c1446a2fd 100644 (file)
@@ -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()
index 4041a480b3142f3548abc248d8ec01209eef227a..3cbbfcfa4e4fdd3e08a6c4d0e34e1be6f4800ca9 100644 (file)
@@ -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,12 +327,18 @@ 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" {
-               c.noDuffDevice = true
-               c.useSSE = false
+       // 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 {