From 37a038a3dcbba7148b841e31522b33476ee6ad44 Mon Sep 17 00:00:00 2001 From: Alberto Donizetti Date: Fri, 23 Feb 2018 11:42:49 +0100 Subject: [PATCH] cmd/compile: add code generation tests for sqrt intrinsics Add "sqrt-intrisified" code generation tests for mips64 and 386, where we weren't intrisifying math.Sqrt (see CL 96615 and CL 95916), and for mips and amd64, which lacked sqrt intrinsics tests. Change-Id: I0cfc08aec6eefd47f3cd7a5995a89393e8b7ed9e Reviewed-on: https://go-review.googlesource.com/96716 Run-TryBot: Alberto Donizetti Reviewed-by: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/cmd/compile/internal/gc/asm_test.go | 48 ++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/src/cmd/compile/internal/gc/asm_test.go b/src/cmd/compile/internal/gc/asm_test.go index 3ccf046555..cceaa798fc 100644 --- a/src/cmd/compile/internal/gc/asm_test.go +++ b/src/cmd/compile/internal/gc/asm_test.go @@ -230,7 +230,7 @@ var allAsmTests = []*asmTests{ { arch: "386", os: "linux", - imports: []string{"encoding/binary"}, + imports: []string{"encoding/binary", "math"}, tests: linux386Tests, }, { @@ -254,13 +254,14 @@ var allAsmTests = []*asmTests{ { arch: "mips", os: "linux", - imports: []string{"math/bits"}, + imports: []string{"math/bits", "math"}, tests: linuxMIPSTests, }, { - arch: "mips64", - os: "linux", - tests: linuxMIPS64Tests, + arch: "mips64", + os: "linux", + imports: []string{"math"}, + tests: linuxMIPS64Tests, }, { arch: "ppc64le", @@ -822,6 +823,14 @@ var linuxAMD64Tests = []*asmTest{ }`, pos: []string{"\tPOPCNTQ\t", "support_popcnt"}, }, + { + fn: ` + func $(x float64) float64 { + return math.Sqrt(x) + } + `, + pos: []string{"SQRTSD"}, + }, // multiplication merging tests { fn: ` @@ -1909,6 +1918,16 @@ var linux386Tests = []*asmTest{ `, neg: []string{"memmove"}, }, + + // Intrinsic tests for math + { + fn: ` + func $(x float64) float64 { + return math.Sqrt(x) + } + `, + pos: []string{"FSQRT|SQRTSD"}, // 387|sse2 + }, } var linuxS390XTests = []*asmTest{ @@ -2906,6 +2925,7 @@ var linuxARM64Tests = []*asmTest{ } var linuxMIPSTests = []*asmTest{ + // Intrinsic tests for math/bits { fn: ` func f0(a uint64) int { @@ -2986,6 +3006,15 @@ var linuxMIPSTests = []*asmTest{ `, pos: []string{"\tCLZ\t"}, }, + // Intrinsic tests for math. + { + fn: ` + func $(x float64) float64 { + return math.Sqrt(x) + } + `, + pos: []string{"SQRTD"}, + }, { // check that stack store is optimized away fn: ` @@ -3009,6 +3038,15 @@ var linuxMIPS64Tests = []*asmTest{ pos: []string{"SLLV\t\\$17"}, neg: []string{"SGT"}, }, + // Intrinsic tests for math. + { + fn: ` + func $(x float64) float64 { + return math.Sqrt(x) + } + `, + pos: []string{"SQRTD"}, + }, } var linuxPPC64LETests = []*asmTest{