]> Cypherpunks repositories - gostls13.git/commit
[dev.ssa] cmd/compile: better register allocator
authorKeith Randall <khr@golang.org>
Thu, 17 Dec 2015 18:01:24 +0000 (10:01 -0800)
committerKeith Randall <khr@golang.org>
Mon, 21 Dec 2015 23:12:05 +0000 (23:12 +0000)
commit7d9f1067d1c8a2d0252fa2a115f1d016f94f7087
treeef655a345667fd21416907cef77fb77a5a1ac4d7
parent5b355a7907550d6fe457fdf6a92fc320d5a764d5
[dev.ssa] cmd/compile: better register allocator

Reorder how register & stack allocation is done.  We used to allocate
registers, then fix up merge edges, then allocate stack slots.  This
lead to lots of unnecessary copies on merge edges:

v2 = LoadReg v1
v3 = StoreReg v2

If v1 and v3 are allocated to the same stack slot, then this code is
unnecessary.  But at regalloc time we didn't know the homes of v1 and
v3.

To fix this problem, allocate all the stack slots before fixing up the
merge edges.  That way, we know what stack slots values use so we know
what copies are required.

Use a good technique for shuffling values around on merge edges.

Improves performance of the go1 TimeParse benchmark by ~12%

Change-Id: I731f43e4ff1a7e0dc4cd4aa428fcdb97812b86fa
Reviewed-on: https://go-review.googlesource.com/17915
Reviewed-by: David Chase <drchase@google.com>
src/cmd/compile/internal/ssa/compile.go
src/cmd/compile/internal/ssa/flagalloc.go
src/cmd/compile/internal/ssa/regalloc.go
src/cmd/compile/internal/ssa/stackalloc.go