summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRuixin(Peter) Bao <ruixin.bao@ibm.com>2019-11-26 15:33:37 -0500
committerMichael Munday <mike.munday@ibm.com>2020-03-25 13:10:07 +0000
commit16cfab8d89ec26a71356c73378ab92eafa6a7356 (patch)
tree791a02e574a9eb3635161cf044a1408502412ce0 /test
parent6b6414cab49fcc035e1f20bafdb723077e7d36bb (diff)
downloadgo-git-16cfab8d89ec26a71356c73378ab92eafa6a7356.tar.gz
cmd/compile: use load and test instructions on s390x
The load and test instructions compare the given value against zero and will produce a condition code indicating one of the following scenarios: 0: Result is zero 1: Result is less than zero 2: Result is greater than zero 3: Result is not a number (NaN) The instruction can be used to simplify floating point comparisons against zero, which can enable further optimizations. This CL also reduces the size of .text section of math.test binary by around 0.7 KB (in hexadecimal, from 1358f0 to 135620). Change-Id: I33cb714f0c6feebac7a1c46dfcc735e7daceff9c Reviewed-on: https://go-review.googlesource.com/c/go/+/209159 Reviewed-by: Michael Munday <mike.munday@ibm.com> Run-TryBot: Michael Munday <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'test')
-rw-r--r--test/codegen/floats.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/codegen/floats.go b/test/codegen/floats.go
index 7ec3654981..117805a2c7 100644
--- a/test/codegen/floats.go
+++ b/test/codegen/floats.go
@@ -122,6 +122,16 @@ func Cmp(f float64) bool {
return f > 4 || f < -4
}
+func CmpZero64(f float64) bool {
+ // s390x:"LTDBR",-"FCMPU"
+ return f <= 0
+}
+
+func CmpZero32(f float32) bool {
+ // s390x:"LTEBR",-"CEBR"
+ return f <= 0
+}
+
// ---------------- //
// Non-floats //
// ---------------- //