]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: add code generation tests for sqrt intrinsics
authorAlberto Donizetti <alb.donizetti@gmail.com>
Fri, 23 Feb 2018 10:42:49 +0000 (11:42 +0100)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Fri, 23 Feb 2018 16:48:53 +0000 (16:48 +0000)
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 <alb.donizetti@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/asm_test.go

index 3ccf0465556dc2fcd6b2bd05b3dab06b4cd7566d..cceaa798fcc337d74d02085a0661da76bc005b99 100644 (file)
@@ -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{