]> Cypherpunks repositories - gostls13.git/commitdiff
test/codegen: port 2^n muls tests to codegen harness
authorAlberto Donizetti <alb.donizetti@gmail.com>
Thu, 8 Mar 2018 09:57:10 +0000 (10:57 +0100)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Thu, 8 Mar 2018 16:30:14 +0000 (16:30 +0000)
And delete them from the asm_test.go file.

Change-Id: I124c8c352299646ec7db0968cdb0fe59a3b5d83d
Reviewed-on: https://go-review.googlesource.com/99475
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
src/cmd/compile/internal/gc/asm_test.go
test/codegen/arithmetic.go [new file with mode: 0644]

index 0e39d0df3e559b2884a68dbdae38616ec4b2f247..1e3cbfe16f3993e0918a68473df14dcc486fc9de 100644 (file)
@@ -272,26 +272,6 @@ var allAsmTests = []*asmTests{
 }
 
 var linuxAMD64Tests = []*asmTest{
-       // multiplication by powers of two
-       {
-               fn: `
-               func $(n int) int {
-                       return n * 64
-               }
-               `,
-               pos: []string{"\tSHLQ\t\\$6,"},
-               neg: []string{"IMULQ"},
-       },
-       {
-               fn: `
-               func $(n int) int {
-                       return -128*n
-               }
-               `,
-               pos: []string{"SHLQ"},
-               neg: []string{"IMULQ"},
-       },
-
        {
                fn: `
                func $(x int) int {
@@ -927,26 +907,6 @@ var linuxAMD64Tests = []*asmTest{
 }
 
 var linux386Tests = []*asmTest{
-       // multiplication by powers of two
-       {
-               fn: `
-               func $(n int) int {
-                       return 32*n
-               }
-               `,
-               pos: []string{"SHLL"},
-               neg: []string{"IMULL"},
-       },
-       {
-               fn: `
-               func $(n int) int {
-                       return -64*n
-               }
-               `,
-               pos: []string{"SHLL"},
-               neg: []string{"IMULL"},
-       },
-
        // multiplication merging tests
        {
                fn: `
@@ -1155,26 +1115,6 @@ var linuxS390XTests = []*asmTest{
 }
 
 var linuxARMTests = []*asmTest{
-       // multiplication by powers of two
-       {
-               fn: `
-               func $(n int) int {
-                       return 16*n
-               }
-               `,
-               pos: []string{"\tSLL\t[$]4"},
-               neg: []string{"\tMUL\t"},
-       },
-       {
-               fn: `
-               func $(n int) int {
-                       return -32*n
-               }
-               `,
-               pos: []string{"\tSLL\t[$]5"},
-               neg: []string{"\tMUL\t"},
-       },
-
        {
                fn: `
                func f0(x uint32) uint32 {
@@ -1222,26 +1162,6 @@ var linuxARMTests = []*asmTest{
 }
 
 var linuxARM64Tests = []*asmTest{
-       // multiplication by powers of two
-       {
-               fn: `
-               func $(n int) int {
-                       return 64*n
-               }
-               `,
-               pos: []string{"\tLSL\t[$]6"},
-               neg: []string{"\tMUL\t"},
-       },
-       {
-               fn: `
-               func $(n int) int {
-                       return -128*n
-               }
-               `,
-               pos: []string{"\tLSL\t[$]7"},
-               neg: []string{"\tMUL\t"},
-       },
-
        {
                fn: `
                func f0(x uint64) uint64 {
diff --git a/test/codegen/arithmetic.go b/test/codegen/arithmetic.go
new file mode 100644 (file)
index 0000000..c09fad6
--- /dev/null
@@ -0,0 +1,26 @@
+// asmcheck
+
+// Copyright 2018 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.
+
+package codegen
+
+// This file contains codegen tests related to arithmetic
+// simplifications/optimizations.
+
+func Pow2Muls(n1, n2 int) (int, int) {
+       // amd64:"SHLQ\t[$]5",-"IMULQ"
+       // 386:"SHLL\t[$]5",-"IMULL"
+       // arm:"SLL\t[$]5",-"MUL"
+       // arm64:"LSL\t[$]5",-"MUL"
+       a := n1 * 32
+
+       // amd64:"SHLQ\t[$]6",-"IMULQ"
+       // 386:"SHLL\t[$]6",-"IMULL"
+       // arm:"SLL\t[$]6",-"MUL"
+       // arm64:"LSL\t[$]6",-"MUL"
+       b := -64 * n2
+
+       return a, b
+}