diff options
| author | Michael Munday <mike.munday@ibm.com> | 2020-02-23 22:08:24 +0000 |
|---|---|---|
| committer | Michael Munday <mike.munday@ibm.com> | 2020-02-26 10:32:22 +0000 |
| commit | 44fe355694798b5e1c55fc087e697886e93e633e (patch) | |
| tree | cc404bad694b7d8bc7ff6e0a10641fcc6584bf46 /test/codegen | |
| parent | e6d7326fb661f9754300d6b9fc5fbb2ee2e4a46b (diff) | |
| download | go-44fe355694798b5e1c55fc087e697886e93e633e.tar.xz | |
cmd/compile: canonicalize comparison argument order
Ensure that any comparison between two values has the same argument
order. This helps ensure that they can be eliminated during the
lowered CSE pass which will be particularly important if we eliminate
the Greater and Geq ops (see #37316).
Example:
CMP R0, R1
BLT L1
CMP R1, R0 // different order, cannot eliminate
BEQ L2
CMP R0, R1
BLT L1
CMP R0, R1 // same order, can eliminate
BEQ L2
This does have some drawbacks. Notably comparisons might 'flip'
direction in the assembly output after even small changes to the
code or compiler. It should help make optimizations more reliable
however.
compilecmp master -> HEAD
master (218f4572f5): text/template: make reflect.Value indirections more robust
HEAD (f1661fef3e): cmd/compile: canonicalize comparison argument order
platform: linux/amd64
file before after Δ %
api 6063927 6068023 +4096 +0.068%
asm 5191757 5183565 -8192 -0.158%
cgo 4893518 4901710 +8192 +0.167%
cover 5330345 5326249 -4096 -0.077%
fix 3417778 3421874 +4096 +0.120%
pprof 14889456 14885360 -4096 -0.028%
test2json 2848138 2844042 -4096 -0.144%
trace 11746239 11733951 -12288 -0.105%
total 132739173 132722789 -16384 -0.012%
Change-Id: I11736b3fe2a4553f6fc65018f475e88217fa22f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/220425
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/codegen')
| -rw-r--r-- | test/codegen/compare_and_branch.go | 8 | ||||
| -rw-r--r-- | test/codegen/condmove.go | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/test/codegen/compare_and_branch.go b/test/codegen/compare_and_branch.go index 33d8d7bd52..23e7810b31 100644 --- a/test/codegen/compare_and_branch.go +++ b/test/codegen/compare_and_branch.go @@ -11,7 +11,7 @@ func dummy() {} // Signed 64-bit compare-and-branch. func si64(x, y chan int64) { - // s390x:"CGRJ\t[$]4, R[0-9]+, R[0-9]+, " + // s390x:"CGRJ\t[$](2|4), R[0-9]+, R[0-9]+, " for <-x < <-y { dummy() } @@ -47,7 +47,7 @@ func si64x8() { // Unsigned 64-bit compare-and-branch. func ui64(x, y chan uint64) { - // s390x:"CLGRJ\t[$]2, R[0-9]+, R[0-9]+, " + // s390x:"CLGRJ\t[$](2|4), R[0-9]+, R[0-9]+, " for <-x > <-y { dummy() } @@ -83,7 +83,7 @@ func ui64x8() { // Signed 32-bit compare-and-branch. func si32(x, y chan int32) { - // s390x:"CRJ\t[$]4, R[0-9]+, R[0-9]+, " + // s390x:"CRJ\t[$](2|4), R[0-9]+, R[0-9]+, " for <-x < <-y { dummy() } @@ -119,7 +119,7 @@ func si32x8() { // Unsigned 32-bit compare-and-branch. func ui32(x, y chan uint32) { - // s390x:"CLRJ\t[$]2, R[0-9]+, R[0-9]+, " + // s390x:"CLRJ\t[$](2|4), R[0-9]+, R[0-9]+, " for <-x > <-y { dummy() } diff --git a/test/codegen/condmove.go b/test/codegen/condmove.go index bd3fe59427..00118d1b63 100644 --- a/test/codegen/condmove.go +++ b/test/codegen/condmove.go @@ -32,7 +32,7 @@ func cmovuintptr(x, y uintptr) uintptr { x = -y } // amd64:"CMOVQCS" - // arm64:"CSEL\tLO" + // arm64:"CSEL\t(LO|HI)" // wasm:"Select" return x } @@ -42,7 +42,7 @@ func cmov32bit(x, y uint32) uint32 { x = -y } // amd64:"CMOVLCS" - // arm64:"CSEL\tLO" + // arm64:"CSEL\t(LO|HI)" // wasm:"Select" return x } @@ -52,7 +52,7 @@ func cmov16bit(x, y uint16) uint16 { x = -y } // amd64:"CMOVWCS" - // arm64:"CSEL\tLO" + // arm64:"CSEL\t(LO|HI)" // wasm:"Select" return x } |
