summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles L. Dorian <cldorian@gmail.com>2010-05-18 22:33:50 -0700
committerCharles L. Dorian <cldorian@gmail.com>2010-05-18 22:33:50 -0700
commitcedb54490a281d2fce83ef36f8b00bf8e08b8a53 (patch)
treeb2a8f1e374097b480bb08ddf06222cfb0ba06ba0
parent4518bb741791a5d7dc251e47abc1b89152e19261 (diff)
downloadgolang-cedb54490a281d2fce83ef36f8b00bf8e08b8a53.tar.gz
math: amd64 versions of fdim, fmax, fmin
Uses the SSE2 max, min instructions. Also shorter sqrt_amd64.s R=rsc CC=golang-dev http://codereview.appspot.com/1216042 Committer: Russ Cox <rsc@golang.org>
-rw-r--r--src/pkg/math/Makefile1
-rw-r--r--src/pkg/math/fdim_amd64.s26
-rw-r--r--src/pkg/math/fdim_decl.go9
-rw-r--r--src/pkg/math/sqrt_amd64.s3
4 files changed, 37 insertions, 2 deletions
diff --git a/src/pkg/math/Makefile b/src/pkg/math/Makefile
index e8edd3505..1447fc11d 100644
--- a/src/pkg/math/Makefile
+++ b/src/pkg/math/Makefile
@@ -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
index 000000000..1f45ef8b9
--- /dev/null
+++ b/src/pkg/math/fdim_amd64.s
@@ -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
index 000000000..88dea3de4
--- /dev/null
+++ b/src/pkg/math/fdim_decl.go
@@ -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
diff --git a/src/pkg/math/sqrt_amd64.s b/src/pkg/math/sqrt_amd64.s
index e98daebf9..f5b329e70 100644
--- a/src/pkg/math/sqrt_amd64.s
+++ b/src/pkg/math/sqrt_amd64.s
@@ -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