]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: don't shuffle rematerializeable values around
authorKeith Randall <khr@golang.org>
Wed, 5 Oct 2016 21:35:47 +0000 (14:35 -0700)
committerKeith Randall <khr@golang.org>
Thu, 6 Oct 2016 02:46:43 +0000 (02:46 +0000)
commit1bddd2ee6aed261830131f824fe32e07de326066
tree95a16c4231e83ca878fa459265023b6df8da0d55
parente5421e21effb5b1db4e565babbddffeb4103d40e
cmd/compile: don't shuffle rematerializeable values around

Better to just rematerialize them when needed instead of
cross-register spilling or other techniques for keeping them in
registers.

This helps for amd64 code that does 1 << x. It is better to do
  loop:
    MOVQ $1, AX  // materialize arg to SLLQ
    SLLQ CX, AX
    ...
    goto loop
than to do
  MOVQ $1, AX    // materialize outsize of loop
  loop:
    MOVQ AX, DX  // save value that's about to be clobbered
    SLLQ CX, AX
    MOVQ DX, AX  // move it back to the correct register
    goto loop

Update #16092

Change-Id: If7ac290208f513061ebb0736e8a79dcb0ba338c0
Reviewed-on: https://go-review.googlesource.com/30471
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/regalloc.go