cmd/compile: add s390x intrinsics for Ceil, Floor, Round and Trunc

Ceil, Floor and Trunc are pre-existing intrinsics. Round is a new
function and has been added as an intrinsic in this CL. All of the
functions can be implemented as a single 'LOAD FP INTEGER'
instruction, FIDBR, on s390x.

name   old time/op  new time/op  delta
Ceil   2.34ns ± 0%  0.85ns ± 0%  -63.74%  (p=0.000 n=5+4)
Floor  2.33ns ± 0%  0.85ns ± 1%  -63.35%  (p=0.008 n=5+5)
Round  4.23ns ± 0%  0.85ns ± 0%  -79.89%  (p=0.000 n=5+4)
Trunc  2.35ns ± 0%  0.85ns ± 0%  -63.83%  (p=0.029 n=4+4)

Change-Id: Idee7ba24a2899d12bf9afee4eedd6b4aaad3c510
Reviewed-on: https://go-review.googlesource.com/63890
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Michael Munday 2017-09-14 20:00:02 +01:00
parent 8802b188c6
commit 7582494e06
8 changed files with 159 additions and 8 deletions

View file

@ -1457,6 +1457,39 @@ var linuxS390XTests = []*asmTest{
`,
pos: []string{"\tFLOGR\t"},
},
// Intrinsic tests for math.
{
fn: `
func ceil(x float64) float64 {
return math.Ceil(x)
}
`,
pos: []string{"\tFIDBR\t[$]6"},
},
{
fn: `
func floor(x float64) float64 {
return math.Floor(x)
}
`,
pos: []string{"\tFIDBR\t[$]7"},
},
{
fn: `
func round(x float64) float64 {
return math.Round(x)
}
`,
pos: []string{"\tFIDBR\t[$]1"},
},
{
fn: `
func trunc(x float64) float64 {
return math.Trunc(x)
}
`,
pos: []string{"\tFIDBR\t[$]5"},
},
{
// check that stack store is optimized away
fn: `