• Keith Randall's avatar
    cmd/compile: don't shuffle rematerializeable values around · 1bddd2ee
    Keith Randall authored
    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: default avatarCherry Zhang <cherryyz@google.com>
    1bddd2ee
regalloc.go 75.2 KB