• Cherry Zhang's avatar
    [dev.ssa] cmd/compile: don't sink spills that satisfy merge edges in SSA · 7bd88a65
    Cherry Zhang authored
    If a spill is used to satisfy a merge edge (in shuffle), don't sink
    it out of loop.
    
    This is found in the following code (on ARM) where there is a stack
    Phi (v268) inside a loop (b36 -> ... -> b47 -> b38 -> b36).
    
    (before shuffle)
      b36: <- b34 b38
        ...
        v268 = Phi <int> v410 v360 : autotmp_198[int]
        ...
        ... -> b47
      b47: <- b44
        ...
        v360 = ... : R6
        v230 = StoreReg <int> v360 : autotmp_198[int]
        v261 = CMPconst <flags> [0] v360
        EQ v261 -> b49 b38 (unlikely)
      b38: <- b47
        ...
        Plain -> b36
    
    During shuffle, v230 (as spill of v360) is found to satisfy v268, but
    it didn't record its use in shuffle, and v230 is sunk out of the loop
    (to b49), which leads to bad value in v268.
    
    This seems never happened on AMD64 (in make.bash), until 4 registers
    are removed.
    
    Change-Id: I01dfc28ae461e853b36977c58bcfc0669e556660
    Reviewed-on: https://go-review.googlesource.com/24858Reviewed-by: default avatarDavid Chase <drchase@google.com>
    7bd88a65
regalloc.go 69.9 KB