diff options
| author | Alberto Donizetti <alb.donizetti@gmail.com> | 2018-03-22 15:00:12 +0100 |
|---|---|---|
| committer | Alberto Donizetti <alb.donizetti@gmail.com> | 2018-03-22 17:20:09 +0000 |
| commit | fc6280d4b01923dd377fa92a2b5dcaef5b253ef3 (patch) | |
| tree | ba9a54b24e1c5c57a0f635d4002a389d997e87e1 /test | |
| parent | 6633bb2aa7c8ab53dc6cc8a4ef8c4fef7a439cee (diff) | |
| download | go-fc6280d4b01923dd377fa92a2b5dcaef5b253ef3.tar.xz | |
test/codegen: port direct comparisons with memory tests
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>
Diffstat (limited to 'test')
| -rw-r--r-- | test/codegen/comparisons.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/codegen/comparisons.go b/test/codegen/comparisons.go index 40a1714519..c0824e6ed1 100644 --- a/test/codegen/comparisons.go +++ b/test/codegen/comparisons.go @@ -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 +} |
