cmd/compile: intrinsify math.Sqrt when compiling "math" itself

Fixes #17354.

Change-Id: I0e018c8c3e791fc6cc1925dbbc18c2151ba9a111
Reviewed-on: https://go-review.googlesource.com/30539
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Cherry Zhang 2016-10-06 10:16:17 -04:00
parent 4f3a641e6e
commit 8aadcc551e

View file

@ -693,7 +693,8 @@ opswitch:
n.Left = walkexpr(n.Left, init)
walkexprlist(n.List.Slice(), init)
if n.Left.Op == ONAME && n.Left.Sym.Name == "Sqrt" && n.Left.Sym.Pkg.Path == "math" {
if n.Left.Op == ONAME && n.Left.Sym.Name == "Sqrt" &&
(n.Left.Sym.Pkg.Path == "math" || n.Left.Sym.Pkg == localpkg && myimportpath == "math") {
if Thearch.LinkArch.InFamily(sys.AMD64, sys.ARM, sys.ARM64, sys.PPC64, sys.S390X) {
n.Op = OSQRT
n.Left = n.List.First()