]> Cypherpunks repositories - gostls13.git/commitdiff
test/codegen: port direct comparisons with memory tests
authorAlberto Donizetti <alb.donizetti@gmail.com>
Thu, 22 Mar 2018 14:00:12 +0000 (15:00 +0100)
committerAlberto Donizetti <alb.donizetti@gmail.com>
Thu, 22 Mar 2018 17:20:09 +0000 (17:20 +0000)
And remove them from asm_test.

Change-Id: I1ca29b40546d6de06f20bfd550ed8ff87f495454
Reviewed-on: https://go-review.googlesource.com/102115
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/asm_test.go
test/codegen/comparisons.go

index f8ba22dddb0c71664b92ae7c71955abe7bd56c24..de59b232a537cbedf5a073f49a87a05856048414 100644 (file)
@@ -394,55 +394,6 @@ var linuxAMD64Tests = []*asmTest{
                `,
                pos: []string{"TEXT\t.*, [$]0-8"},
        },
-       // int <-> fp moves
-       {
-               fn: `
-               func $(x uint32) bool {
-                       return x > 4
-               }
-               `,
-               pos: []string{"\tSETHI\t.*\\(SP\\)"},
-       },
-       {
-               fn: `
-               func $(p int, q *int) bool {
-                       return p < *q
-               }
-               `,
-               pos: []string{"CMPQ\t\\(.*\\), [A-Z]"},
-       },
-       {
-               fn: `
-               func $(p *int, q int) bool {
-                       return *p < q
-               }
-               `,
-               pos: []string{"CMPQ\t\\(.*\\), [A-Z]"},
-       },
-       {
-               fn: `
-               func $(p *int) bool {
-                       return *p < 7
-               }
-               `,
-               pos: []string{"CMPQ\t\\(.*\\), [$]7"},
-       },
-       {
-               fn: `
-               func $(p *int) bool {
-                       return 7 < *p
-               }
-               `,
-               pos: []string{"CMPQ\t\\(.*\\), [$]7"},
-       },
-       {
-               fn: `
-               func $(p **int) {
-                       *p = nil
-               }
-               `,
-               pos: []string{"CMPL\truntime.writeBarrier\\(SB\\), [$]0"},
-       },
 }
 
 var linux386Tests = []*asmTest{
index 40a171451959be772e699edc7753a156e2ef0c6d..c0824e6ed16c6f9d2a50f6d518f41e6427cdb55b 100644 (file)
@@ -67,3 +67,42 @@ func CompareArray6(a, b unsafe.Pointer) bool {
        // amd64:`CMPL\t\(.*\), [A-Z]`
        return *((*[4]byte)(a)) != *((*[4]byte)(b))
 }
+
+// -------------- //
+//    Ordering    //
+// -------------- //
+
+// Test that LEAQ/ADDQconst are folded into SETx ops
+
+func CmpFold(x uint32) bool {
+       // amd64:`SETHI\t.*\(SP\)`
+       return x > 4
+}
+
+// Test that direct comparisons with memory are generated when
+// possible
+
+func CmpMem1(p int, q *int) bool {
+       // amd64:`CMPQ\t\(.*\), [A-Z]`
+       return p < *q
+}
+
+func CmpMem2(p *int, q int) bool {
+       // amd64:`CMPQ\t\(.*\), [A-Z]`
+       return *p < q
+}
+
+func CmpMem3(p *int) bool {
+       // amd64:`CMPQ\t\(.*\), [$]7`
+       return *p < 7
+}
+
+func CmpMem4(p *int) bool {
+       // amd64:`CMPQ\t\(.*\), [$]7`
+       return 7 < *p
+}
+
+func CmpMem5(p **int) {
+       // amd64:`CMPL\truntime.writeBarrier\(SB\), [$]0`
+       *p = nil
+}