]> Cypherpunks repositories - gostls13.git/commitdiff
math: optimize Ceil, Floor and Trunc on s390x
authorMichael Munday <munday@ca.ibm.com>
Fri, 26 Aug 2016 15:39:47 +0000 (11:39 -0400)
committerMichael Munday <munday@ca.ibm.com>
Fri, 26 Aug 2016 17:27:13 +0000 (17:27 +0000)
Use the FIDBR instruction to round floating-point numbers to integers.

name   old time/op  new time/op  delta
Ceil   14.1ns ± 0%   3.0ns ± 0%  -78.89%  (p=0.000 n=10+10)
Floor  6.42ns ± 0%  3.03ns ± 0%  -52.80%  (p=0.000 n=10+10)
Trunc  6.67ns ± 0%  3.03ns ± 0%  -54.57%   (p=0.000 n=10+9)

Change-Id: I3b416f6d0bccaaa9b547de86356471365862399c
Reviewed-on: https://go-review.googlesource.com/27827
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/math/floor_s390x.s [new file with mode: 0644]
src/math/stubs_s390x.s

diff --git a/src/math/floor_s390x.s b/src/math/floor_s390x.s
new file mode 100644 (file)
index 0000000..896e79b
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright 2016 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.
+
+#include "textflag.h"
+
+// func Floor(x float64) float64
+TEXT ·Floor(SB),NOSPLIT,$0
+       FMOVD   x+0(FP), F0
+       FIDBR   $7, F0, F0
+       FMOVD   F0, ret+8(FP)
+       RET
+
+// func Ceil(x float64) float64
+TEXT ·Ceil(SB),NOSPLIT,$0
+       FMOVD   x+0(FP), F0
+       FIDBR   $6, F0, F0
+       FMOVD   F0, ret+8(FP)
+       RET
+
+// func Trunc(x float64) float64
+TEXT ·Trunc(SB),NOSPLIT,$0
+       FMOVD   x+0(FP), F0
+       FIDBR   $5, F0, F0
+       FMOVD   F0, ret+8(FP)
+       RET
index 76868447cd5704450fff9268f16a855d3c378444..c3aed13e87975e876dbf5b4132b7990cdd53999b 100644 (file)
@@ -25,15 +25,6 @@ TEXT ·Expm1(SB),NOSPLIT,$0
 TEXT ·Exp(SB),NOSPLIT,$0
        BR ·exp(SB)
 
-TEXT ·Floor(SB),NOSPLIT,$0
-       BR ·floor(SB)
-
-TEXT ·Ceil(SB),NOSPLIT,$0
-       BR ·ceil(SB)
-
-TEXT ·Trunc(SB),NOSPLIT,$0
-       BR ·trunc(SB)
-
 TEXT ·Frexp(SB),NOSPLIT,$0
        BR ·frexp(SB)