]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: implement comparisons directly with memory
authorKeith Randall <khr@google.com>
Wed, 3 Jan 2018 22:38:55 +0000 (14:38 -0800)
committerKeith Randall <khr@golang.org>
Mon, 26 Feb 2018 23:49:44 +0000 (23:49 +0000)
commit4b00d3f4a2d1379377a0f2312564ae405b946d65
tree47f957045026cb93fff0ef2a2c893245f4a9f767
parent30673769ed7409da0ba1046e874371bf4f07d352
cmd/compile: implement comparisons directly with memory

Allow the compiler to generate code like CMPQ 16(AX), $7

It's tricky because it's difficult to spill such a comparison during
flagalloc, because the same memory state might not be available at
the restore locations.

Solve this problem by decomposing the compare+load back into its parts
if it needs to be spilled.

The big win is that the write barrier test goes from:

MOVL runtime.writeBarrier(SB), CX
TESTL CX, CX
JNE 60

to

CMPL runtime.writeBarrier(SB), $0
JNE 59

It's one instruction and one byte smaller.

Fixes #19485
Fixes #15245
Update #22460

Binaries are about 0.15% smaller.

Change-Id: I4fd8d1111b6b9924d52f9a0901ca1b2e5cce0836
Reviewed-on: https://go-review.googlesource.com/86035
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/gc/asm_test.go
src/cmd/compile/internal/ssa/flagalloc.go
src/cmd/compile/internal/ssa/func.go
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/gen/AMD64Ops.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewriteAMD64.go
src/cmd/compile/internal/ssa/schedule.go