]> Cypherpunks repositories - gostls13.git/commitdiff
math: amd64 versions of fdim, fmax, fmin
authorCharles L. Dorian <cldorian@gmail.com>
Wed, 19 May 2010 05:33:50 +0000 (22:33 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 19 May 2010 05:33:50 +0000 (22:33 -0700)
Uses the SSE2 max, min instructions. Also shorter sqrt_amd64.s

R=rsc
CC=golang-dev
https://golang.org/cl/1216042

src/pkg/math/Makefile
src/pkg/math/fdim_amd64.s [new file with mode: 0644]
src/pkg/math/fdim_decl.go [new file with mode: 0644]
src/pkg/math/sqrt_amd64.s

index e8edd350509899e9ca960baff32ad01af50532de..1447fc11d405d0d1e41638e8c31757628a1d5554 100644 (file)
@@ -7,6 +7,7 @@ include ../../Make.$(GOARCH)
 TARG=math
 
 OFILES_amd64=\
+       fdim_amd64.$O\
        sqrt_amd64.$O\
 
 OFILES_386=\
diff --git a/src/pkg/math/fdim_amd64.s b/src/pkg/math/fdim_amd64.s
new file mode 100644 (file)
index 0000000..1f45ef8
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2010 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// func Fdim(x, y float64) float64
+TEXT ·Fdim(SB),7,$0
+       MOVSD x+0(FP), X0
+       SUBSD y+8(FP), X0
+       MOVSD $(0.0), X1
+       MAXSD X1, X0
+       MOVSD X0, r+16(FP)
+       RET
+
+// func Fmax(x, y float64) float64
+TEXT ·Fmax(SB),7,$0
+       MOVSD x+0(FP), X0
+       MAXSD y+8(FP), X0
+       MOVSD X0, r+16(FP)
+       RET
+
+// func Fmin(x, y float64) float64
+TEXT ·Fmin(SB),7,$0
+       MOVSD x+0(FP), X0
+       MINSD y+8(FP), X0
+       MOVSD X0, r+16(FP)
+       RET
diff --git a/src/pkg/math/fdim_decl.go b/src/pkg/math/fdim_decl.go
new file mode 100644 (file)
index 0000000..88dea3d
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2010 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package math
+
+func Fdim(x, y float64) float64
+func Fmax(x, y float64) float64
+func Fmin(x, y float64) float64
index e98daebf9b4dbb9239013d662b70392cbda85ab1..f5b329e70a874d07d7d4fe17dcf1fd3b3c25df17 100644 (file)
@@ -4,7 +4,6 @@
 
 // func Sqrt(x float64) float64
 TEXT ·Sqrt(SB),7,$0
-       MOVSD x+0(FP), X0
-       SQRTSD X0, X0
+       SQRTSD x+0(FP), X0
        MOVSD X0, r+8(FP)
        RET